public JsonResult UpdateStoreData(Store store) { using (TransactionEntities db = new TransactionEntities()) { if (ModelState.IsValid) { try { db.Entry(store).State = EntityState.Modified; db.SaveChanges(); } catch (DbUpdateConcurrencyException) { var result = db.Stores.SingleOrDefault(a => a.Id == store.Id); if (result == null) { return(Json(new { success = false, message = "Cannot find store to update" }, JsonRequestBehavior.AllowGet)); } else { throw; } } return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } } return(Json(new { success = false, message = "Invalid store given" }, JsonRequestBehavior.AllowGet)); }