public IActionResult AddDish() { // List<Chef> AllChefs = dbContext.Chefs.ToList(); oneDishAndAllChefs ViewModel = new oneDishAndAllChefs() { oneDish = new Dish(), AllChefs = dbContext.Chefs.ToList() }; // ViewBag.Chefs = AllChefs; return(View("AddDishPage", ViewModel)); }
public IActionResult AddDishForm(oneDishAndAllChefs FromForm) { if (ModelState.IsValid) { dbContext.Dishes.Add(FromForm.oneDish); dbContext.SaveChanges(); return(RedirectToAction("DisplayDishes")); } else { return(View("AddDishPage", FromForm)); } }