public void AddToCart(Product product, int amount) { var shoppingCardItem = GetCartItemById(product.Id); if (shoppingCardItem == null) { shoppingCardItem = new ShoppingCartItem() { ShoppingCartId = Id, Product = product, Amount = amount }; _worldTechDbContext.ShoppingCartItems.Add(shoppingCardItem); } else { shoppingCardItem.Amount++; } _worldTechDbContext.SaveChanges(); }
public void Save() => _worldtechContext.SaveChanges();