예제 #1
0
        public IActionResult CreatePizzaPost(PizzaViewModel pvm)
        {
            if (pvm.Name == 0 || pvm.Size == 0 || pvm.Price == 0)
            {
                return(View("BadRequest"));
            }

            Pizza pizza = new Pizza();

            pizza    = PizzaMapper.PVMToPizza(pvm);
            pizza.Id = (StaticDb.Pizzas.Count) + 1;
            StaticDb.Pizzas.Add(pizza);
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public IActionResult EditPizzaPost(PizzaViewModel pvm)
        {
            //try
            //{
            Pizza pizza = PizzaMapper.PVMToPizza(pvm);

            if (pizza == null)
            {
                return(View("ResourceNotFound"));
            }
            int index = StaticDb.Pizzas.FindIndex(x => x.Id == pizza.Id);

            StaticDb.Pizzas[index] = pizza;
            return(RedirectToAction("Index"));

            //}
            //catch
            //{
            //return View("InternalServerError");
            //}
        }