From ef33cb199cfbce8ba428381113c7ae78347a3e44 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Thu, 8 Dec 2022 18:28:28 -0800 Subject: [PATCH] Update InvoiceController.cs --- .../Controllers/InvoiceController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs index 10fa620..43f8342 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs @@ -178,6 +178,13 @@ public class InvoiceController : Controller { inv.Products = new(); + try { + prods = _context.Products.Where(x => sinv.ProdQuant.Select(x => x.Key).Contains(x.Id)).ToList(); + } catch (Exception e) { + _logger.LogError(8, e.Message); + return BadRequest(); + } + foreach (var prod in prods) { inv.Products.Add(new() { Product = prod, @@ -267,13 +274,6 @@ public class InvoiceController : Controller { }; inv.ShippingAddress = ad; - - try { - prods = _context.Products.Where(x => sinv.ProdQuant.Select(x => x.Key).Contains(x.Id)).ToList(); - } catch (Exception e) { - _logger.LogError(8, e.Message); - return BadRequest(); - } if (prods.Count == 0) return BadRequest("Vous devez inclure au moins un produit à votre commande.");