public ActionResult New() { ISession se = NHibernateHelper.CurrentSession; EmployeeView e = new EmployeeView { Employee = new Employee(), Employeecontact = new Employeecontact(), Employeejob = new Employeejob(), Employeesalary = new Employeesalary(), Employeequalification = new Employeequalification() }; ViewBag.form_id = "add-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 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); }