예제 #1
0
        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();
        }
예제 #2
0
 public void Save() => _worldtechContext.SaveChanges();