public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Directions")] Recipe recipe) { if (id != recipe.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recipe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeExists(recipe.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(recipe)); }
public async Task <IActionResult> Edit(int id, [Bind("RecipeId,IngredientId,Measurement")] RecipeIngredient recipeIngredient) { if (id != recipeIngredient.RecipeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recipeIngredient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeIngredientExists(recipeIngredient.RecipeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IngredientId"] = new SelectList(_context.Ingredients, "Id", "Id", recipeIngredient.IngredientId); ViewData["RecipeId"] = new SelectList(_context.Recipes, "Id", "Id", recipeIngredient.RecipeId); return(View(recipeIngredient)); }