// Returns a complete list of employees public ActionResult Employees() { // Null handling if (Session["loggedInState"] == null) { return Redirect("/403.html"); } // If logged in bool state = (bool)Session["loggedInState"]; if (state == true) { // Creates models var employeeModel = new EmployeeModel(); var departmentModel = new DepartmentModel(); var roleModel = new RoleModel(); var depotModel = new DepotModel(); // Gets the complete list List<Employee> el = employeeModel.GetEmployeesList(); if (el.Count != 0) { // Attaches associated department / role to employee foreach (var employee in el) { // Acquires, and adds the employee depot Depot depot = null; if (employee.Depot != 0) { depot = depotModel.SearchDepot(employee.Depot); } // Acquires, and adds the employee department Department dept = null; if (employee.Dept != 0) { dept = departmentModel.SearchDepartment(employee.Dept); } // Acquires, and adds the employee role Role role = null; if (employee.Role != 0) { role = roleModel.SearchRoles(employee.Role); } // Appends objects to employee employee.DepotO = depot; employee.Department = dept; employee.RoleO = role; } // Returns the list return View(el); } else { return Redirect("/403.html"); } } else { // If not logged in return Redirect("/login.html"); } }
public ActionResult Edit() { int id = int.Parse(RouteData.Values["ID"].ToString()); var roleEditor = new RoleModel(); Role editingRole = roleEditor.SearchRoles(id); return View(editingRole); }