Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Codecool.CodecoolShop/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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 = "",
Expand Down Expand Up @@ -194,4 +194,4 @@ public IActionResult Error()
{
return View(new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier});
}
}
}