public async Task <IActionResult> Create([Bind("Id,Name")] Ingredient ingredient) { if (ModelState.IsValid) { _context.Add(ingredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ingredient)); }
public async Task <IActionResult> Create([Bind("RecipeId,IngredientId,Measurement")] RecipeIngredient recipeIngredient) { if (ModelState.IsValid) { _context.Add(recipeIngredient); await _context.SaveChangesAsync(); 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)); }