public IActionResult CustomPizza()
        {
            if (currUser == null)
            {
                return(RedirectToAction("Login", "User"));
            }

            Dictionary <Toppings, bool> top = new Dictionary <Toppings, bool>();

            foreach (var topping in _pR.GetToppingTypes())
            {
                top.Add(topping, false);
            }



            CustomPizzaViewModel customPizzaModel = new CustomPizzaViewModel()
            {
                SelectedCheeseId  = 1,
                SelectedCrustId   = 1,
                SelectedSauceId   = 1,
                SelectedSizeId    = 1,
                SelectedToppingId = 1,
            };

            ViewData["cheeses"]  = _pR.GetCheeseTypes();
            ViewData["sauces"]   = _pR.GetSauceTypes();
            ViewData["crusts"]   = _pR.GetCrustTypes();
            ViewData["sizes"]    = _pR.GetSizeTypes();
            ViewData["toppings"] = _pR.GetToppingTypes();

            return(View(customPizzaModel));
        }
Exemplo n.º 2
0
        public IActionResult CustomMenu()
        {
            CustomPizzaViewModel customPizzaViewModel = new CustomPizzaViewModel()
            {
                Crusts   = _repo.ReadCrusts(),
                Sizes    = _repo.ReadSizes(),
                Toppings = _repo.ReadToppings()
            };

            return(View(customPizzaViewModel));
        }
        public IActionResult Preset(int?id)

        {
            if (id == null)

            {
                return(NotFound());
            }

            if (currUser == null)

            {
                return(RedirectToAction("Login", "User"));
            }



            Pizza p = _pR.GetPizzaById(id.Value);



            CustomPizzaViewModel cpVM = new CustomPizzaViewModel()

            {
                Name = p.Name,

                SelectedCrustId = p.CrustId.Value,

                SelectedCheeseId = p.CheeseId.Value,

                SelectedSauceId = p.SauceId.Value,

                SelectedSizeId = p.SizeId.Value,

                SelectedToppingId = p.ToppingId.Value,
            };



            return(RedirectToAction("Confirmation", cpVM));
        }
Exemplo n.º 4
0
        public IActionResult AddCustom(CustomPizzaViewModel customPizzaViewModel)
        {
            if (ModelState.IsValid)
            {
                if (customPizzaViewModel.SelectedToppings.Count < 2 || customPizzaViewModel.SelectedToppings.Count > 5)
                {
                    ViewData["Status"] = "Cannot add pizza; number of toppings must be between 2 and 5";
                }

                else if (_repo.Read((int)TempData.Peek("OrderId")).Pizzas.Count == 50)
                {
                    ViewData["Status"] = "Cannot add pizza; number of pizzas in an order cannot exceed 50.";
                }

                else if (_repo.ReadNewPrice(customPizzaViewModel.Crust, customPizzaViewModel.Size, customPizzaViewModel.SelectedToppings, (int)TempData.Peek("OrderId")) > 250.00m)
                {
                    ViewData["Status"] = "Cannot add pizza; price of the order cannot exceed $250";
                }

                //Create Pizza
                else
                {
                    _repo.CreateCustomPizza(customPizzaViewModel.Crust, customPizzaViewModel.Size, customPizzaViewModel.SelectedToppings, (int)TempData.Peek("OrderId"));
                    ViewData["Status"] = "Added new custom 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));
            }

            customPizzaViewModel.Crusts   = _repo.ReadCrusts();
            customPizzaViewModel.Sizes    = _repo.ReadSizes();
            customPizzaViewModel.Toppings = _repo.ReadToppings();
            return(View("CustomMenu", customPizzaViewModel));
        }
        public IActionResult Confirmation(CustomPizzaViewModel C)
        {
            if (currUser == null)

            {
                return(RedirectToAction("Login", "User"));
            }
            Pizza p = _pR.MapPizzaByIDs(C.SelectedCrustId, C.SelectedSauceId, C.SelectedCheeseId, C.SelectedSizeId, C.SelectedToppingId);

            _oR.SetCurrentPizza(p);
            string pizzaName;



            if (C.Name == "" || C.Name == null)

            {
                pizzaName = "CustomPizza";
            }
            else

            {
                pizzaName = C.Name;
            }
            PizzaViewModel pizzaVM = new PizzaViewModel()
            {
                Cheese  = p.Cheese,
                Sauce   = p.Sauce,
                Size    = p.Size,
                Crust   = p.Crust,
                Topping = p.Topping,
                Price   = _pR.GetPriceByPizza(p)
            };

            return(View(pizzaVM));
        }