コード例 #1
0
        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++;
        }
コード例 #2
0
 public IActionResult New(ShoppingItem newItem)
 {
     return RedirectToAction("Index");
 }