// // GET: /User/User/ public ActionResult Index() { object id = Session["employee_id"]; ViewBag.employee_salary = EmployeesalaryHelper.Find(id); ViewBag.pay_type = ViewBag.employee_salary.Paytype; return(View()); }
// // GET: /User/Salary/ public async Task <ActionResult> Index() { ISession se = NHibernateHelper.CurrentSession; SalaryView o = new SalaryView(); object id = Session["employee_id"]; Employee employee = se.Get <Employee>(id); o.Employeesalary = EmployeesalaryHelper.Find(id); double adjustment = await SalaryadjustmentHelper.GetSalaryAdjustment(new Dictionary <string, object> { { "staff_id", employee.Staffid }, { "year", DateTime.Now.Year } }); o.BasicPay = o.Employeesalary.Salary + adjustment; return(View(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)); }