// GET: Dishes/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var dish = await _context.Dishes.Include(d => d.DishIngredients).SingleOrDefaultAsync(m => m.DishId == id); var ingredients = await _context.Ingredients.ToListAsync(); if (dish == null) { return(NotFound()); } var vm = new ManageDishViewModel { DishId = dish.DishId, Name = dish.Name, CategoryId = dish.CategoryId, Price = dish.Price, ImageUrl = dish.ImageUrl, DishIngredients = dish.DishIngredients, Ingredients = ingredients }; return(View(vm)); }
// GET: Dishes/Create public IActionResult Create() { var vm = new ManageDishViewModel { Ingredients = _context.Ingredients.ToList() }; return(View(vm)); }