public IActionResult PresetMenu() { PresetPizzaViewModel presetPizzaViewModel = new PresetPizzaViewModel() { PresetPizzas = _repo.ReadPresetPizzas() }; return(View(presetPizzaViewModel)); }
public IActionResult AddPreset(PresetPizzaViewModel presetPizzaViewModel) { if (ModelState.IsValid) { //Check that the number of pizzas doesn't exceed 50 if (_repo.Read((int)TempData.Peek("OrderId")).Pizzas.Count == 50) { ViewData["Status"] = "Cannot add pizza; number of pizzas in an order cannot exceed 50."; } //Check that price doesn't exceed $250 else if (_repo.ReadNewPrice(presetPizzaViewModel.Name, (int)TempData.Peek("OrderId")) > 250.00m) { ViewData["Status"] = "Cannot add pizza; price of the order cannot exceed $250"; } //Create Pizza else { _repo.CreatePresetPizza(presetPizzaViewModel.Name, (int)TempData.Peek("OrderId")); ViewData["Status"] = "Added new preset pizza!"; } //Return to menu with new OrderMenu OrderMenuViewModel orderMenuViewModel = new OrderMenuViewModel() { Order = _repo.Read((int)TempData.Peek("OrderId")), Status = (string)ViewData["Status"] }; return(View("Menu", orderMenuViewModel)); } presetPizzaViewModel.PresetPizzas = _repo.ReadPresetPizzas(); return(View("PresetMenu", presetPizzaViewModel)); }