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.Entry(category).State = EntityState.Modified;
            //var entry = Context.Entry(category);
            //Context.Categories.Attach(category);
            //entry.State = EntityState.Modified;
            Context.SaveChanges();
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "Id,City,StreetName,WorkTime,OnlineOrder")] Shop shop)
 {
     if (ModelState.IsValid)
     {
         db.Entry(shop).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(shop));
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Id,Name")] City city)
 {
     if (ModelState.IsValid)
     {
         db.Entry(city).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(city));
 }
예제 #4
0
 public ActionResult Edit([Bind(Include = "Id,Type,Bedrooms,Rooms,Area,Floor,ResidentialDistrict,City,Price,Year,Extras")] Property property)
 {
     if (ModelState.IsValid)
     {
         db.Entry(property).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(property));
 }