From 15b06a9a3060e2d7e6ca11bd5c5257b44b961b9e Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:55:35 -0800 Subject: [PATCH 1/2] Update InvoiceController.cs --- .../GrossesMitainesAPI/Controllers/InvoiceController.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs index 567efe0..d26290d 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs @@ -158,6 +158,10 @@ public class InvoiceController : Controller { return BadRequest(); } + + if (prods.Count == 0) + return BadRequest("Vous devez inclure au moins un produit à votre commande."); + foreach (var prod in prods) { inv.Products.Add(new() { Product = prod, @@ -165,9 +169,6 @@ public class InvoiceController : Controller { }); } - if (prods.Count == 0) - return BadRequest("Vous devez inclure au moins un produit à votre commande."); - foreach (var prod in sinv.ProdQuant) { // Update de quantités dans l'inventaire. ProductModel inventProd = prods.Where(x => x.Id == prod.Key).First(); if (inventProd.Quantity < prod.Value) From 71762040440b58596f3c33e83ac015239118540c Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Wed, 23 Nov 2022 17:06:55 -0800 Subject: [PATCH 2/2] =?UTF-8?q?AH=20BEN=20KA=C3=8FN!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GrossesMitainesAPI/Controllers/InvoiceController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs index d26290d..045a7c2 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs @@ -162,6 +162,8 @@ public class InvoiceController : Controller { if (prods.Count == 0) return BadRequest("Vous devez inclure au moins un produit à votre commande."); + inv.Products = new(); + foreach (var prod in prods) { inv.Products.Add(new() { Product = prod,