示例#1
0
        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);
        }
示例#2
0
        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();
        }
示例#3
0
 public void CreatePie(Pie pie)
 {
     _appDbContext.Pies.Add(pie);
     _appDbContext.SaveChanges();
 }
示例#4
0
 public void UpdatePie(Pie pie)
 {
     _appDbContext.Pies.Update(pie);
     _appDbContext.SaveChanges();
 }
示例#5
0
 public void UpdatePie(Pie pie)
 {
 }
示例#6
0
 public void CreatePie(Pie pie)
 {
 }