public void Update(Ratings rating) { var ratingInDb = db.Ratings.Find(rating.RatingID); if (ratingInDb == null) { return; } db.Entry(ratingInDb).CurrentValues.SetValues(rating); db.Entry(ratingInDb).State = EntityState.Modified; db.SaveChanges(); }
public void Update(T item, Func <T, bool> findByIDPredecate) { var local = Context.Set <T>() .Local .FirstOrDefault(findByIDPredecate); if (local != null) { Context.Entry(local).State = EntityState.Detached; } Context.Entry(item).State = EntityState.Modified; Context.SaveChanges(); }
public void Update(T entity) { var entry = db.Entry(entity); entry.State = EntityState.Modified; db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "Id,Name,Description,Ingredients,Directions,Source,Category,Image_URL")] Recipe recipe) { if (ModelState.IsValid) { db.Entry(recipe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recipe)); }