예제 #1
0
        public IEnumerable <Person> AddPerson(Person person)
        {
            _addDbContext.Add(person);
            _addDbContext.SaveChanges();

            return(_addDbContext.Persons.Include(c => c.Color));
        }
        public void AddToCart(Drink drink, int amount)
        {
            var shoppingCartItem =
                _appDbContext.shopingCartItems.SingleOrDefault(
                    s => s.Drink.DrinkID == drink.DrinkID && s.ShoppingCartId == ShoppingCartId);

            if (shoppingCartItem == null)
            {
                shoppingCartItem = new ShopingCartItem
                {
                    ShoppingCartId = ShoppingCartId,
                    Drink          = drink,
                    Amount         = 1
                };

                _appDbContext.shopingCartItems.Add(shoppingCartItem);
            }
            else
            {
                shoppingCartItem.Amount++;
            }
            _appDbContext.SaveChanges();
        }