//Create public bool Create(IngredientViewCreateModel model) { var ingredient = new Ingredient { UserId = model.UserId, Name = model.Name }; ingredient = ingredientRepo.Create(ingredient); return(ingredient.Id != 0); }
public ActionResult Create(IngredientViewCreateModel model) { if (!ModelState.IsValid) { return(View(model)); } model.UserId = Guid.Parse(User.Identity.GetUserId()); if (IngredientService.Create(model)) { TempData["SaveResult"] = "Your ingredient was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Ingredient could not be created."); return(View(model)); }
//GET public ActionResult Create() { IngredientViewCreateModel model = new IngredientViewCreateModel(); return(View(model)); }