// GET: Department public ActionResult Index() { if (System.Web.HttpContext.Current.Session["employeeId"] == null) { return(RedirectToAction("Index", "Login")); } DepartmentService departmentService = new DepartmentService(); List <DepartmentLookup> departments = new List <DepartmentLookup>(); if ((int)Session["employeeType"] == (int)EmployeeType.HRSupervisor || (int)Session["employeeType"] == (int)EmployeeType.HREmployee) { departments = departmentService.GetDepartmentLookups(); } else { Department department = departmentService.GetDepartment((int)Session["employeeId"]); DepartmentLookup dep = new DepartmentLookup() { Id = department.DepartmentId, Name = department.Name }; departments.Add(dep); } return(View(departments)); }
public List <DepartmentLookup> GetDepartmentLookups() { DataAccess db = new DataAccess(); DataTable dt = db.Execute("GetDepartmentLookups", CommandType.StoredProcedure); List <DepartmentLookup> departments = new List <DepartmentLookup>(); foreach (DataRow row in dt.Rows) { DepartmentLookup department = new DepartmentLookup() { Id = Convert.ToInt32(row["DepartmentId"]), Name = row["Name"].ToString() }; departments.Add(department); } return(departments); }
protected override IEnumerable GetList() { return(InnerList ?? (InnerList = DepartmentLookup.GetList().Result)); }