Exemplo n.º 1
0
        public void AddCateringToOrder(ShoppingCartLunch customLunch)
        {
            var result = new ShoppingCartComboCatering
            {
                BookingId = _cartSession.BookingId,
                Lunch     = customLunch.Lunch,
                LunchId   = customLunch.Lunch.LunchId,
                Created   = _calendarRepository.LocalTime(),
                Amount    = 1
            };

            _appDbContext.ShoppingCartCaterings.Add(result);
            _appDbContext.SaveChanges();
        }
Exemplo n.º 2
0
        public void AddCateringToCart(Lunch catering, int amount)
        {
            var shoppingCartCatering = AllShoppingCartCaterings().FirstOrDefault(
                s => s.Lunch == catering && s.BookingId == _cartSession.BookingId);

            if (shoppingCartCatering == null)
            {
                shoppingCartCatering = new ShoppingCartComboCatering
                {
                    BookingId = _cartSession.BookingId,
                    Lunch     = catering,
                    LunchId   = catering.LunchId,
                    Created   = _calendarRepository.LocalTime(),
                    Amount    = amount
                };
                _appDbContext.ShoppingCartCaterings.Add(shoppingCartCatering);
            }
            else
            {
                shoppingCartCatering.Amount = amount + shoppingCartCatering.Amount;
                _appDbContext.ShoppingCartCaterings.Update(shoppingCartCatering);
            }
            _appDbContext.SaveChanges();
        }