// // GET: /CompleteEmployeeList/ public ActionResult CompleteEmployeeList() { using (var db = new HR_QueryEntities()) { List<Employee> query = db.Employees.Select(x => x).Where(x => x.Available == true).ToList(); foreach (Employee e in query) { EmployeeQueryModel model = new EmployeeQueryModel(); model.EmployeeID = e.Employee_ID; model.EmployeeLastName = e.Last_Name; model.SearchedCriteria = (db.Departments.Select(x => x).Where(x => x.Dept_ID == e.Department).First()).Dept_Name; modelItems.Add(model); } return View(modelItems); } }
// // GET: /FilteredEmployeeList/ public ActionResult FilteredEmployeeList(int _selectedId, int _searchType) { using (var db = new HR_QueryEntities()) { if (_searchType == 1) { List<Employee> query = db.Employees.Select(x => x).Where(x => x.Department == _selectedId && x.Available == true).ToList(); if(query.Count == 0) return RedirectToAction("NullEmployeeList"); ViewBag.Message = "Employee Department"; foreach (Employee e in query) { EmployeeQueryModel model = new EmployeeQueryModel(); model.EmployeeID = e.Employee_ID; model.EmployeeLastName = e.Last_Name; model.SearchedCriteria = (db.Departments.Select(x => x).Where(x => x.Dept_ID == e.Department).First()).Dept_Name; modelItems.Add(model); } } else if (_searchType == 2) { List<Employee> query = db.Employees.Select(x => x).Where(x => x.Location == _selectedId && x.Available == true).ToList(); if (query.Count == 0) return RedirectToAction("NullEmployeeList"); ViewBag.Message = "Employee Location"; foreach (Employee e in query) { EmployeeQueryModel model = new EmployeeQueryModel(); model.EmployeeID = e.Employee_ID; model.EmployeeLastName = e.Last_Name; model.SearchedCriteria = (db.Locations.Select(x => x).Where(x => x.Location_ID == e.Location).First()).Location_Name; modelItems.Add(model); } } else { List<Employee> query = db.Employees.Select(x => x).Where(x => x.Position_Type == _selectedId && x.Available == true).ToList(); if (query.Count == 0) return RedirectToAction("NullEmployeeList"); ViewBag.Message = "Employee Position Type"; foreach (Employee e in query) { EmployeeQueryModel model = new EmployeeQueryModel(); model.EmployeeID = e.Employee_ID; model.EmployeeLastName = e.Last_Name; model.SearchedCriteria = (db.Position_Types.Select(x => x).Where(x => x.Position_Type_ID == e.Position_Type).First()).Position_Type_Name; modelItems.Add(model); } } return View(modelItems); } }