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")); }
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"); //} }