public async Task <ActionResult> Create(FormCollection fc) { Department o = DepartmentHelper.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", "Department was successfully added." } }, JsonRequestBehavior.AllowGet)); } else { return(Json(err, JsonRequestBehavior.AllowGet)); } }