public IActionResult EditIngredient(string Id) { Ingredient ingredient = _adminManager.FindIngredientById(Id); if (ingredient == null) { return(NotFound()); } CreateEditIngredientModel model = new CreateEditIngredientModel { Id = ingredient.Id, Name = ingredient.Name, Price = ingredient.Price }; return(View(model)); }
public IActionResult CreateIngredient(CreateEditIngredientModel model) { if (ModelState.IsValid) { IngredientDTO ingredient = new IngredientDTO { Name = model.Name, Price = model.Price }; var result = _adminManager.CreateIngredient(ingredient); if (result.Succedeed) { return(RedirectToAction("Ingredients")); } else { ModelState.AddModelError(result.Property, result.Message); } } return(View(model)); }