public void AddItem(ShoppingItem shoppingItem) { // //C# 6 Demo // if (shoppingItem == null) // throw new ArgumentNullException(nameof(shoppingItem)); var cartItem = CartItems.FirstOrDefault(i => i.ShoppingItem.Id == shoppingItem.Id); if (cartItem == null) CartItems.Add(new CartItem { ShoppingItem = shoppingItem, Quantity = 1 }); else cartItem.Quantity++; }
public IActionResult New(ShoppingItem newItem) { return RedirectToAction("Index"); }