From f50794492b76e703b8e46e9be4e2c011ca572947 Mon Sep 17 00:00:00 2001 From: qbunia Date: Mon, 20 Feb 2023 22:18:20 +0100 Subject: [PATCH] Update CartController.cs --- src/Codecool.CodecoolShop/Controllers/CartController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Codecool.CodecoolShop/Controllers/CartController.cs b/src/Codecool.CodecoolShop/Controllers/CartController.cs index 06ead5a..5744d52 100644 --- a/src/Codecool.CodecoolShop/Controllers/CartController.cs +++ b/src/Codecool.CodecoolShop/Controllers/CartController.cs @@ -91,7 +91,7 @@ public IActionResult Add(int? id) private void IncreaseProductQuantity(int? id) { var product = _context.OrderedProducts.Include(p => p.Order) - .First(p => p.ProductId == id && p.Order.OrderPayed == "No"); + .First(p => p.ProductId == id && p.Order.OrderPayed == "No"); //parametr id jest nullable wiec na pewno ktos poda nulla keidys tam. Strzelisz do bazy danych z nullem na ProudctId. Baza nie najdzie takiego rekordu i poleci exception. Popraw tak by obsluzyc taki przypadek. product.Quantity++; _context.SaveChanges(); } @@ -105,7 +105,7 @@ private void AddNewProductToCart(int? id) { var address = new Address { - City = "", + City = "", //czemu nie null albo String.Empty? Czy nie mozna w Address stworzyc statycznej klasy typu Address.CreateEmpty() i tam zainicjalizowac to do pustych stringow? Country = "", Email = "", FullName = "", @@ -194,4 +194,4 @@ public IActionResult Error() { return View(new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier}); } -} \ No newline at end of file +}