public async Task <ActionResult> Create(FormCollection fc) { Designation o = DesignationHelper.GetObject(null, fc); Dictionary <string, object> err = null; ISession se = NHibernateHelper.CurrentSession; err = o.IsValid(se); if (err == null) { await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.SaveOrUpdate(o); tx.Commit(); } }); return(Json(new Dictionary <string, object> { { "success", 1 }, { "message", "Job Title was successfully added." } }, JsonRequestBehavior.AllowGet)); } else { return(Json(err, JsonRequestBehavior.AllowGet)); } }
public async Task <JsonResult> Update(int id, FormCollection fc) { Dictionary <string, object> err = null; Designation o = null; ISession se = NHibernateHelper.CurrentSession; o = await Task.Run(() => { return(se.Get <Designation>(id)); }); o = DesignationHelper.GetObject(o, fc); err = o.IsValid(se); if (err == null) { await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.SaveOrUpdate(o); tx.Commit(); } }); return(Json(new Dictionary <string, object> { { "success", 1 }, { "message", "Department was successfully updated." } }, JsonRequestBehavior.AllowGet)); } else { return(Json(err, JsonRequestBehavior.AllowGet)); } }