public int RemoveFromCart(Pie pie) { var shoppingCartItem = _appDbContext.ShoppingCartItems.SingleOrDefault(a => a.Pie.PieId == pie.PieId && a.ShoppingCartId == ShoppingCartId); var localAmout = 0; if (shoppingCartItem != null) { if (shoppingCartItem.Amount > 1) { shoppingCartItem.Amount--; localAmout = shoppingCartItem.Amount; } else { _appDbContext.ShoppingCartItems.Remove(shoppingCartItem); } } _appDbContext.SaveChanges(); return(localAmout); }
public void AddToCart(Pie pie, int amount) { var shoppingCartItem = _appDbContext.ShoppingCartItems.SingleOrDefault(s => s.Pie.PieId == pie.PieId && s.ShoppingCartId == ShoppingCartId); if (shoppingCartItem == null) { shoppingCartItem = new ShoppingCartItem { ShoppingCartId = ShoppingCartId, Amount = amount, Pie = pie }; _appDbContext.ShoppingCartItems.Add(shoppingCartItem); } else { shoppingCartItem.Amount++; } _appDbContext.SaveChanges(); }
public void CreatePie(Pie pie) { _appDbContext.Pies.Add(pie); _appDbContext.SaveChanges(); }
public void UpdatePie(Pie pie) { _appDbContext.Pies.Update(pie); _appDbContext.SaveChanges(); }
public void UpdatePie(Pie pie) { }
public void CreatePie(Pie pie) { }