public async Task <IActionResult> Edit(int id, [Bind("Id,R_id,I_id,Weight")] MyRecipe_Ingredient myRecipe_Ingredient) { if (id != myRecipe_Ingredient.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(myRecipe_Ingredient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MyRecipe_IngredientExists(myRecipe_Ingredient.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["I_id"] = new SelectList(_context.Ingredient, "Id", "Id", myRecipe_Ingredient.I_id); ViewData["R_id"] = new SelectList(_context.MyRecipe, "Id", "Id", myRecipe_Ingredient.R_id); return(View(myRecipe_Ingredient)); }
public async Task <IActionResult> Create([Bind("Id,R_id,I_id,Weight")] MyRecipe_Ingredient myRecipe_Ingredient) { if (ModelState.IsValid) { _context.Add(myRecipe_Ingredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["I_id"] = new SelectList(_context.Ingredient, "Id", "Id", myRecipe_Ingredient.I_id); ViewData["R_id"] = new SelectList(_context.MyRecipe, "Id", "Id", myRecipe_Ingredient.R_id); return(View(myRecipe_Ingredient)); }