public int SaveLunch(string bookingId = null) { var result = 0; ShoppingCartLunch lunch = _cartRepository.GetSessionLunch(bookingId); if (lunch != null) { result = lunch.Lunch.LunchId; _appDbContext.ShoppingCartCustomLunch.Remove(lunch); if (GetTotal(lunch.Lunch) == 0) { _appDbContext.Lunch.Remove(lunch.Lunch); } else { if (lunch.Lunch.ComboPrice == 0) { lunch.Lunch.ComboPrice = GetTotal(lunch.Lunch); _appDbContext.Lunch.Update(lunch.Lunch); } } _appDbContext.SaveChanges(); } return(result); }
public ShoppingCartLunch GetSessionLunch(string bookingId = null) { bookingId = bookingId ?? GetSessionCartId(); ShoppingCartLunch result = _appDbContext.ShoppingCartCustomLunch .Include(x => x.Lunch) .Include(x => x.Lunch.Miscellanea) .Include(x => x.Lunch.Items) .ThenInclude(x => x.Product) .FirstOrDefault(x => x.BookingId == bookingId); return(result); }
public void ModifyLunch(int id) { SaveLunch(); var lunch = GetLunch(id); var result = new ShoppingCartLunch { BookingId = _cartRepository.GetSessionCartId(), Lunch = lunch }; _appDbContext.ShoppingCartCustomLunch.Add(result); _appDbContext.SaveChanges(); }
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(); }
public async Task ModifyLunchAsync(int id) { SaveLunch(); var lunch = await GetLunchByIdAsync(id); var result = new ShoppingCartLunch { BookingId = _cartRepository.GetSessionCartId(), Lunch = lunch, Created = _calendar.LocalTime() }; _appDbContext.ShoppingCartCustomLunch.Add(result); _appDbContext.SaveChanges(); }
public int SaveLunch(string bookingId = null) { var result = 0; ShoppingCartLunch cartLunch = _cartRepository.GetSessionLunch(bookingId); if (cartLunch != null) { result = cartLunch.Lunch.LunchId; _appDbContext.ShoppingCartCustomLunch.Remove(cartLunch); if (GetTotal(cartLunch.Lunch) == 0) { _appDbContext.Lunch.Remove(cartLunch.Lunch); } _appDbContext.SaveChanges(); } return(result); }
public ShoppingCartLunch GetOrCreateSessionLunch(string bookingId = null) { bookingId = bookingId ?? GetSessionCartId(); var result = GetSessionLunch(bookingId); if (result == null) { result = new ShoppingCartLunch { BookingId = bookingId, Lunch = new Lunch() { PreparationTime = 24, } }; _appDbContext.ShoppingCartCustomLunch.Add(result); _appDbContext.SaveChanges(); } return(result); }