public ActionResult Custodian() { AssignmentProcess assignProcess = new AssignmentProcess(); AccessRightsProcess accessProcess = new AccessRightsProcess(); GenericProcess <vwFixAssetList> fixAssetProcess = new GenericProcess <vwFixAssetList>(); List <vwAssetAssignmentsForCustodian> acceptances = new List <vwAssetAssignmentsForCustodian>(); List <vwFixAssetList> releases = new List <vwFixAssetList>(); List <vwFixAssetList> repairs = new List <vwFixAssetList>(); List <AccessRight> accessRights = new List <AccessRight>(); accessRights = accessProcess.GetAccessRightsByEmloyeeID(User.Identity.Name.ToInteger()).ToList(); foreach (AccessRight right in accessRights) { acceptances.AddRange(assignProcess.GetAssignmentsForAdminAcceptanceByDepartmentID(right.DepartmentID, User.Identity.Name.ToInteger())); } repairs = assignProcess.GetAssignmentsForRepairs(); releases = assignProcess.GetAssignmentsForReleases(); ViewBag.Acceptances = acceptances; ViewBag.Repairs = repairs; ViewBag.Releases = releases; return(View()); }
public ActionResult DeleteRightFromList(int accessID, int empID) { AccessRightsProcess accessProcess = new AccessRightsProcess(); accessProcess.UserID = User.Identity.Name.ToInteger(); try { if (empID == 0 || accessID == 0) { throw new Exception("Invalid entry. Please check your input."); } else { if (accessProcess.Delete(accessID) == FASTConstant.RETURN_VAL_SUCCESS) { return(RedirectToAction("Index")); } else { throw new Exception("Failed to delete access right"); } } } catch (Exception ex) { TempData[FASTConstant.TMPDATA_RESULT] = FASTConstant.FAILURE; TempData[FASTConstant.TMPDATA_SOURCE] = "Delete Access Right"; TempData[FASTConstant.TMPDATA_EXTRAMESSAGE] = ex.Message; TempData[FASTConstant.TMPDATA_CONTROLLER] = "AccessRight"; TempData[FASTConstant.TMPDATA_ACTION] = "Index"; return(View("~/Views/Shared/Result.cshtml")); } }
public ActionResult MyDepartment(int departmentID) { Session[FASTConstant.SESSION_MYDEPARTMENT] = departmentID; AssignmentProcess assignProcess = new AssignmentProcess(); AccessRightsProcess accessProcess = new AccessRightsProcess(); GenericProcess <vwDepartmentList> deptProcess = new GenericProcess <vwDepartmentList>(); List <vwDepartmentList> departments = new List <vwDepartmentList>(); List <AccessRight> accessRights = accessProcess.GetAccessRightsByEmloyeeID(User.Identity.Name.ToInteger()).ToList(); accessRights = accessProcess.GetAccessRightsByEmloyeeID(User.Identity.Name.ToInteger()) .Where(i => i.AccessLevel == FASTConstant.ACCESS_LVL_MANAGER).ToList(); foreach (AccessRight right in accessRights) { departments.Add(deptProcess.GetAll().Where(i => i.DepartmentID == right.DepartmentID).FirstOrDefault()); } vwDepartmentList theDepartment = deptProcess.GetAll().Where(i => i.DepartmentID == departmentID).First(); List <vwAssetAssignmentsForManager> approvals = assignProcess.GetAssignmentsForManagerApprovalByDepartmentID(departmentID, User.Identity.Name.ToInteger()); ViewBag.Approvals = approvals; ViewBag.MyDepartments = departments; TempData["Department"] = theDepartment; return(View()); }
public ActionResult AddAccessRight(int employeeID = 0, int accessID = 0, int departmentID = 0) { AccessRightsProcess accessProcess = new AccessRightsProcess(); accessProcess.UserID = User.Identity.Name.ToInteger(); AccessRight newRight = new AccessRight() { AccessLevel = (short)accessID, DepartmentID = departmentID, EmployeeID = employeeID }; try { if (employeeID == 0 || accessID == 0 || (departmentID == 0 && accessID != FASTConstant.ACCESS_LVL_APPADMIN)) { throw new Exception("Invalid entry. Please check your input."); } else { if (accessProcess.AddNewRight(newRight) == FASTConstant.RETURN_VAL_SUCCESS) { return(RedirectToAction("SearchEmployeeRights", new { employeeID = employeeID })); } else { throw new Exception("Failed to add access right"); } } } catch (Exception ex) { TempData[FASTConstant.TMPDATA_RESULT] = FASTConstant.FAILURE; TempData[FASTConstant.TMPDATA_SOURCE] = "Add Access Right"; TempData[FASTConstant.TMPDATA_EXTRAMESSAGE] = ex.Message; TempData[FASTConstant.TMPDATA_CONTROLLER] = "AccessRight"; TempData[FASTConstant.TMPDATA_ACTION] = "NewAccessRight"; return(View("~/Views/Shared/Result.cshtml")); } }