Пример #1
0
 public void DeleteProduct(Product p)
 {
     if (p == null)
     {
         throw new ArgumentNullException(nameof(p));
     }
     _context.Remove(p);
 }
Пример #2
0
 public void RemoveOrder(Order order)
 {
     if (order == null)
     {
         throw new ArgumentNullException(nameof(order));
     }
     _context.Remove(order);
 }
 public void DeleteCustomer(Customer c)
 {
     if (c == null)
     {
         throw new ArgumentNullException(nameof(c));
     }
     _context.Remove(c);
     // Removing the address. Maybe this shouldn't be here
     _context.Address.Remove(c.Address);
 }
        public async Task <CartItem> RemoveItemShoppingCart(CartItem cartItem)
        {
            if (cartItem == null)
            {
                throw new ArgumentNullException(nameof(cartItem));
            }
            var cart = await GetShoppingCartAsync(cartItem.ShoppingCartId);

            var product = await _context.Products.FindAsync(cartItem.ProductId);

            if (cartItem.Quantity == 1)
            {
                cartItem.Quantity = 0;
                _context.Remove(cartItem);
                cart.Total -= product.Price;
                return(cartItem);
            }

            cartItem.Quantity--;
            cart.Total -= product.Price;
            return(cartItem);
        }