public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Store store) { if (id != store.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(store); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreExists(store.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(store)); }
public async Task <IActionResult> Edit(int recipeId, int ingredientId, [Bind("RecipeId,IngredientId,Quantity,UnitId")] RecipeIngredient recipeIngredient) { if (recipeId != recipeIngredient.RecipeId || ingredientId != recipeIngredient.IngredientId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recipeIngredient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeIngredientExists(recipeIngredient.RecipeId, recipeIngredient.IngredientId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IngredientId"] = new SelectList(_context.Ingredient, nameof(Ingredient.Id), nameof(Ingredient.Name), recipeIngredient.IngredientId); ViewData["RecipeId"] = new SelectList(_context.Recipe, nameof(Recipe.Id), nameof(Recipe.Name), recipeIngredient.RecipeId); ViewData["UnitId"] = new SelectList(_context.Unit, nameof(Unit.Id), nameof(Unit.Name), recipeIngredient.UnitId); return(View(recipeIngredient)); }
public async Task <IActionResult> Edit(int shoppingListId, int recipeId, [Bind("ShoppingListId,RecipeId,Quantity")] ShoppingListRecipe shoppingListRecipe) { if (shoppingListId != shoppingListRecipe.ShoppingListId || recipeId != shoppingListRecipe.RecipeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shoppingListRecipe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShoppingListRecipeExists(shoppingListRecipe.ShoppingListId, shoppingListRecipe.RecipeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ShoppingListId"] = new SelectList(_context.ShoppingList, nameof(ShoppingList.Id), nameof(ShoppingList.Name), shoppingListRecipe.ShoppingListId); ViewData["RecipeId"] = new SelectList(_context.Recipe, nameof(Recipe.Id), nameof(Recipe.Name), shoppingListRecipe.RecipeId); return(View(shoppingListRecipe)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Servings,ServingsOurs")] 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)); }