public void RemoveShopItem(int id) { var shopItem = _shopItemsContext.ShopItems.SingleOrDefault(s => s.id == id); if (shopItem != null) { _shopItemsContext.Remove(shopItem); } _shopItemsContext.SaveChanges(); }
public void RemoveFromCart(int id) { ShoppingCartId = GetCartId(); var cartItem = _shopItemContext.CartItems.SingleOrDefault( c => c.CartId == ShoppingCartId && c.ShopItemId == id); if (cartItem != null) { cartItem.Quantity--; if (cartItem.Quantity == 0) { _shopItemContext.Remove(cartItem); } } _shopItemContext.SaveChanges(); }