public static Employeequalification GetObject(Employee e, FormCollection fc) { string paramStartdate = GetParam("start_date", fc); DateTime startdate = CommonHelper.GetDateTime(paramStartdate); string paramEnddate = GetParam("end_date", fc); DateTime enddate = CommonHelper.GetDateTime(paramEnddate); string paramLevel = GetParam("level", fc); int level = CommonHelper.GetValue <int>(paramLevel); string paramYear = GetParam("year", fc); int year = CommonHelper.GetValue <int>(paramYear); string paramGpa = GetParam("gpa", fc); double gpa = CommonHelper.GetValue <double>(paramGpa); Employeequalification o = e.Employeequalification; if (o == null) { o = new Employeequalification(); o.Id = e.Id; } o.Level = level; o.Institute = GetParam("institute", fc); o.Major = GetParam("major", fc); o.Year = year; o.Gpa = gpa; o.Startdate = startdate; o.Enddate = enddate; return(o); }
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)); }
// // GET: /User/Qualifications/ public ActionResult Index() { object id = Session["employee_id"]; Employeequalification employee_qualification = EmployeequalificationHelper.Find(id); return(View(employee_qualification)); }
public async Task <ActionResult> Edit(Guid id) { ISession se = NHibernateHelper.CurrentSession; Employee o = await Task.Run(() => { return(se.Get <Employee>(id)); }); Employeecontact oc = o.Employeecontact; Employeejob oej = o.Employeejob; Employeesalary osa = o.Employeesalary; Employeequalification oq = o.Employeequalification; EmployeeView e = new EmployeeView { Employee = o, Employeecontact = oc == null ? new Employeecontact() : oc, Employeejob = oej == null ? new Employeejob() : oej, Employeesalary = osa == null ? new Employeesalary() : osa, Employeequalification = oq == null ? new Employeequalification() : oq }; ViewBag.form_id = "edit-form"; ViewBag.users = se.QueryOver <Domain.Model.User>() .OrderBy(x => x.Username).Asc.List(); ViewBag.designations = se.QueryOver <Designation>() .OrderBy(x => x.Title).Asc.List(); ViewBag.employment_statuses = se.QueryOver <Employmentstatus>() .OrderBy(x => x.Name).Asc.List(); ViewBag.job_categories = se.QueryOver <Jobcategory>() .OrderBy(x => x.Name).Asc.List(); ViewBag.departments = se.QueryOver <Department>() .OrderBy(x => x.Name).Asc.List(); return(View("_form", e)); }
public static Employeequalification Find(object id) { Employeequalification o = null; ISession se = NHibernateHelper.CurrentSession; o = se.Get <Employeequalification>(id); if (o == null) { o = new Employeequalification(); } return(o); }
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)); }