public IActionResult Create(Chef newChef) { if (ModelState.IsValid == false) { return(View("New")); //Just "New" - already in Chef } // ModalState.IsValid... // newDish.CreatedAt = DateTime.Now; //works, but moved to Model's instantiation db.Chefs.Add(newChef); //DB Insert db.SaveChanges(); return(RedirectToAction("Index")); // return RedirectToAction("Details", newDish.DishId); //"Details", new {id = newDish.DishId} }
public IActionResult Create(ChefNDish newChefNDish) //Dish newDish //param retrieval MUST match @model passback! { if (ModelState.IsValid == false) { // return View("New"); //not enough, the Dish/New view also needs ListOfChefs newChefNDish.ListOfChefs = db.Chefs.ToList(); return(View("New", newChefNDish)); } // ModalState.IsValid... //db.Dishes.Add(newChefNDish.NewDish); //DB Insert db.Dishes.Add(newChefNDish.NewDish); db.SaveChanges(); return(RedirectToAction("All")); //"Details", new {id = newDish.DishId} }