public async Task <IActionResult> Create(PizzaFormModel model) { if (!ModelState.IsValid) { return(View(model)); } await this.pizzas.Create( model.Name, model.Description, model.Price, model.ImgUrl); TempData.AddSuccessMessage("Pizza Added Successfully To The Menu!"); return(RedirectToAction(nameof(PizzasController.Index), "Pizzas", new { area = "Admin" })); }
public async Task <IActionResult> Edit(PizzaFormModel model) { if (!ModelState.IsValid) { return(View(model)); } var pizza = await this.pizzas.ById(model.Id); pizza.Price = model.Price; pizza.Description = model.Description; pizza.ImgUrl = model.ImgUrl; pizza.Name = model.Name; this.db.SaveChanges(); TempData.AddSuccessMessage("Pizza Editted Successfully!"); return(RedirectToAction(nameof(PizzasController.Index))); }