public ActionResult Edit([Bind(Include = "IngredientId,IngredientName,IngredientCost")] Ingredient ingredient) { if (ModelState.IsValid) { db.Entry(ingredient).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ingredient)); }
public ActionResult Edit([Bind(Include = "RecipeId,RecipeName")] Recipe recipe) { if (ModelState.IsValid) { db.Entry(recipe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recipe)); }
public ActionResult Edit(Ingredient ingredient, int RecipeId) { if (RecipeId != 0) { _db.IngredientRecipe.Add(new IngredientRecipe() { RecipeId = RecipeId, IngredientId = ingredient.IngredientId }); } _db.Entry(ingredient).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Tag tag, int RecipeId) { if (RecipeId != 0) { _db.RecipeTag.Add(new RecipeTag() { RecipeId = RecipeId, TagId = tag.TagId }); } _db.Entry(tag).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Recipe recipe, int TagId) { if (TagId != 0) { _db.RecipeTag.Add(new RecipeTag() { TagId = TagId, RecipeId = recipe.RecipeId }); } _db.Entry(recipe).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Updates fields of a reicipe. Does not update directions or ingredients for the recipe. /// </summary> /// <param name="recipe"></param> /// <returns></returns> public async Task UpdateRecipe(Recipe recipe) { // This method does not update directions or ingredients. recipe.Directions = null; recipe.Ingredients = null; if (recipe == null) { throw new ArgumentNullException(nameof(recipe)); } if (!await _recipeDb.Recipes.AnyAsync(r => r.Id == recipe.Id)) { throw new ArgumentException($"No recipe found with ID '{recipe.Id}'."); } _recipeDb.Attach <Recipe>(recipe); _recipeDb.Entry <Recipe>(recipe).State = EntityState.Modified; await _recipeDb.SaveChangesAsync(); }
public ActionResult Edit(Instruction Instruction) { _db.Entry(Instruction).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Category category) { _db.Entry(category).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Recipe recipe) { _db.Entry(recipe).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }