//Update public bool Update(IngredientViewEditModel model) { var ingredient = ingredientRepo.GetById(model.Id); ingredient.Name = model.Name; return(ingredientRepo.Update(ingredient)); }
public IngredientViewEditModel GetEditById(int id) { var ingredient = ingredientRepo.GetById(id); var model = new IngredientViewEditModel { Name = ingredient.Name }; return(model); }
public ActionResult Edit(IngredientViewEditModel model) { if (!ModelState.IsValid) { return(View(model)); } if (IngredientService.Update(model)) { TempData["SaveResult"] = "Your ingredient was updated."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Ingredient could not be updated."); return(View(model)); }