public IActionResult Index() { BreakfastOrder breakfastOrder = new BreakfastOrder(); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 1, Name = "Cornflakes", Price = 36, Selected = false }); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 2, Name = "Egg", Price = 36, Selected = false }); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 3, Name = "Toast", Price = 18, Selected = false }); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 4, Name = "Juice", Price = 40, Selected = false }); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 5, Name = "Milk", Price = 24, Selected = false }); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 6, Name = "Coffee", Price = 42, Selected = false }); breakfastOrder.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 7, Name = "Tea", Price = 32, Selected = false }); return(View(breakfastOrder)); }
public void CheckIn(BreakfastOrder model) { using (var transaction = _context.Database.BeginTransaction()) { try { List <BreakfastOrder> BO = _context.BreakfastOrders.Where(BO => BO.Date == DateTime.Today && BO.RoomNumber == model.RoomNumber).ToList(); if (BO.Count == 0) { //Error Response.Redirect("../Home/RestaurantView"); return; } if (BO[0].AmountAdults - BO[0].AdultsCheckedIn >= model.AdultsCheckedIn) { BO[0].AdultsCheckedIn += model.AdultsCheckedIn; } if (BO[0].AmountKids - BO[0].KidsCheckedIn >= model.KidsCheckedIn) { BO[0].KidsCheckedIn += model.KidsCheckedIn; } _context.SaveChanges(); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); } Response.Redirect("../Home/RestaurantView"); } }
public void CreateOrder(BreakfastOrder model) { using (var transaction = _context.Database.BeginTransaction()) { try { List <BreakfastOrder> BO = _context.BreakfastOrders.Where(BO => BO.Date == model.Date && BO.RoomNumber == model.RoomNumber).ToList(); if (BO.Count == 0) { _context.BreakfastOrders.Add(model); _context.SaveChanges(); transaction.Commit(); Response.Redirect("../Home/ReceptionView"); return; } if (BO.Count != 0) { BO[0].AmountAdults += model.AmountAdults; BO[0].AmountKids += model.AmountKids; _context.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } Response.Redirect("../Home/ReceptionView"); } }
public IActionResult Index() { BreakfastOrder room101 = new BreakfastOrder(); room101.AddBreakfastFood(new BreakfastFood { BreakfastFoodId = 1, Name = "Cornflakes", Price = 36, Selected = false }); return(View(room101)); }
public async Task <IActionResult> ReceptionAddGuests( [Bind("RoomNumber,Date,Adults,CheckedInAdults,Children,CheckedInChildren")] BreakfastOrder breakfastOrder) { if (ModelState.IsValid) { _db.Add(breakfastOrder); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(ReceptionAddGuests))); } return(View(breakfastOrder)); }
public IActionResult Index(BreakfastOrder breakfastOrder) { return(View("Receipt", breakfastOrder)); }