public ActionResult PerformUpdate(int key, EmployeeMap value)
public ActionResult PerformInsert(string action, EmployeeMap value)
public ActionResult PerformInsert(string action, EmployeeMap value) { using (ISession session = AppSession.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(value); transaction.Commit(); } list = session.Query<EmployeeMap>().ToList(); } return Json(new { result = value, count = list.Count() }, JsonRequestBehavior.AllowGet); } //PERFORM UPDATE public ActionResult PerformUpdate(int key, EmployeeMap value) { using (ISession session = AppSession.OpenSession()) { var employeetoUpdate = session.Get<EmployeeMap>(key); employeetoUpdate.Designation = value.Designation; employeetoUpdate.FirstName = value.FirstName; employeetoUpdate.LastName = value.LastName; using (ITransaction transaction = session.BeginTransaction()) { session.Save(employeetoUpdate); transaction.Commit(); } list = session.Query<EmployeeMap>().ToList(); } return Json(new { result = value, count = list.Count() }, JsonRequestBehavior.AllowGet); }
I modified the PerformUpdate method so that it returns the following:
return Json(new { Status = "error", Data = "not working!" });
Unfortunately, the event "actionFailure" wasn't even raised..so, my requirement is the following:
How should I modify PerformUpdate and PerformInsert methods (considering that I'm using RemoteSaveAdaptor) in order to correctly trigger ActionFailure() on insert and update actions when the backend raises an exception (because some input data isn't valid)? Thanks a lot for the kind help!
//Perform update public ActionResult PerformUpdate(OrderTable value) { if(value.OrderID>300) // validation get failed throw new Exception("Data is not valid"); // Exception message return Json(value, JsonRequestBehavior.AllowGet); } Javascript //actionFailure event of the Grid function failure(args) { alert(args.error.responseText); //get the exception message } |