// // GET: /User/Qualifications/ public ActionResult Index() { object id = Session["employee_id"]; Employeequalification employee_qualification = EmployeequalificationHelper.Find(id); return(View(employee_qualification)); }
public async Task <JsonResult> Update(FormCollection fc) { ISession se = NHibernateHelper.CurrentSession; object id = Session["employee_id"]; Employeequalification oq = EmployeequalificationHelper.Find(id); Employee o = se.Get <Employee>(id); oq = EmployeequalificationHelper.GetObject(o, fc); Dictionary <string, object> err = oq.IsValid(); if (err != null) { return(Json(err, JsonRequestBehavior.AllowGet)); } await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.SaveOrUpdate(oq); tx.Commit(); } }); return(Json(new Dictionary <string, object> { { "success", 1 }, { "message", "Qualifications was successfully updated." } }, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> Update(Guid id, FormCollection fc) { ISession se = NHibernateHelper.CurrentSession; Employee o = await Task.Run(() => { return(se.Get <Employee>(id)); }); o = await EmployeeHelper.GetObject(se, o, fc); Employeecontact oc = EmployeecontactHelper.GetObject(o, fc); Employeejob oej = await EmployeejobHelper.GetObject(se, o, fc);; Employeesalary osa = EmployeesalaryHelper.GetObject(o, fc); Employeequalification oq = EmployeequalificationHelper.GetObject(o, fc); bool b1 = EmployeecontactHelper.IsEmptyParams(fc); bool b2 = EmployeejobHelper.IsEmptyParams(fc); bool b3 = EmployeesalaryHelper.IsEmptyParams(fc); bool b4 = EmployeequalificationHelper.IsEmptyParams(fc); Dictionary <string, object> employeeErrors = o.IsValid(se); Dictionary <string, object> employeeContactErrors = null; Dictionary <string, object> employeeJobErrors = null; Dictionary <string, object> employeeSalaryErrors = null; Dictionary <string, object> employeeQualificationErrors = null; bool v1 = employeeErrors == null; bool v2 = b1 ? true : (employeeContactErrors = oc.IsValid()) == null; bool v3 = b2 ? true : (employeeJobErrors = oej.IsValid()) == null; bool v4 = b3 ? true : (employeeSalaryErrors = osa.IsValid()) == null; bool v5 = b4 ? true : (employeeQualificationErrors = oq.IsValid()) == null; if (!v1 || !v2 || !v3 || !v4 || !v5) { Dictionary <string, object> err = new Dictionary <string, object> { { "error", 1 }, { "employee", CommonHelper.GetErrors(employeeErrors) }, { "employee_contact", CommonHelper.GetErrors(employeeContactErrors) }, { "employee_job", CommonHelper.GetErrors(employeeJobErrors) }, { "employee_salary", CommonHelper.GetErrors(employeeSalaryErrors) }, { "employee_qualification", CommonHelper.GetErrors(employeeQualificationErrors) } }; return(Json(err, JsonRequestBehavior.AllowGet)); } await Task.Run(() => { using (ITransaction tx = se.BeginTransaction()) { se.SaveOrUpdate(o); if (!b1) { se.SaveOrUpdate(oc); } if (!b2) { se.SaveOrUpdate(oej); } if (!b3) { se.SaveOrUpdate(osa); } if (!b4) { se.SaveOrUpdate(oq); } tx.Commit(); } }); return(Json(new Dictionary <string, object> { { "success", 1 }, { "message", "Employee was successfully updated." } }, JsonRequestBehavior.AllowGet)); }