public void Update(T item, Func <T, bool> findByIDPredecate) { var local = Context.Set <T>() .Local .FirstOrDefault(findByIDPredecate); // (f => f.ID == item.ID); if (local != null) { Context.Entry(local).State = EntityState.Detached; } Context.Entry(item).State = EntityState.Modified; // Context.Entry(category).State = EntityState.Modified; //var entry = Context.Entry(category); //Context.Categories.Attach(category); //entry.State = EntityState.Modified; Context.SaveChanges(); }
public ActionResult Edit([Bind(Include = "Id,ZipCode,StreetName,StreetNum,Extra,CityId,CreatedTime,UpdatedTime")] Location location) { if (ModelState.IsValid) { db.Entry(location).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CityId = new SelectList(db.Cities, "Id", "Name", location.CityId); return(View(location)); }
public ActionResult Edit([Bind(Include = "Id,Name,About,Price,inStoke,Order,LocationId,CreatedTime,UpdatedTime")] CarsParts carsParts) { if (ModelState.IsValid) { db.Entry(carsParts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LocationId = new SelectList(db.Locations, "Id", "ZipCode", carsParts.LocationId); return(View(carsParts)); }