public ActionResult ChangeRepresentative(string employee, string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long deptId = emp.DeptId; long currentRep = DepartmentService.GetCurrentRep(deptId); bool all = DelegateService.CheckPreviousHeadForNav(deptId); bool permanentHead = ((emp.EmpRole == "HEAD" && emp.EmpDisplayRole == "HEAD") || (emp.EmpRole == "EMPLOYEE" && emp.EmpDisplayRole == "HEAD")); ViewData["all"] = all; ViewData["permanentHead"] = permanentHead; if (employee != null) { long newRep = long.Parse(employee); EmailNotification notice = new EmailNotification(); RepresentativeService.UpdateEmployeeRole(newRep, currentRep, deptId); Employee newRepMailReceiver = EmployeeService.GetEmployeeById(newRep); Employee oldRepMailReceiver = EmployeeService.GetEmployeeById(currentRep); Task.Run(() => { notice.ReceiverMailAddress = newRepMailReceiver.Email; emailService.SendMail(notice, EmailTrigger.ON_ASSIGNED_AS_DEPT_REP); notice.ReceiverMailAddress = oldRepMailReceiver.Email; emailService.SendMail(notice, EmailTrigger.ON_REMOVED_DEPT_REP); }); } List <Employee> employees = RepresentativeService.GetEmployeesByDepartment(deptId); ViewData["employees"] = employees; ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult ProcessRequisition(long reqId, string status, string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long currentHead = emp.EmpId; RequisitionService.ProcessRequisition(reqId, status, currentHead); bool all = DelegateService.CheckPreviousHeadForNav(emp.DeptId); bool permanentHead = ((emp.EmpRole == "HEAD" && emp.EmpDisplayRole == "HEAD") || (emp.EmpRole == "EMPLOYEE" && emp.EmpDisplayRole == "HEAD")); ViewData["all"] = all; ViewData["permanentHead"] = permanentHead; ViewData["sessionId"] = sessionId; return(RedirectToAction("GetPendingRequisitions", new { sessionId = sessionId })); }
public ActionResult GetPendingRequisitions(string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long deptId = emp.DeptId; List <Requisition> requisitions = RequisitionService.DisplayPendingRequisitions(deptId); bool all = DelegateService.CheckPreviousHeadForNav(deptId); bool permanentHead = ((emp.EmpRole == "HEAD" && emp.EmpDisplayRole == "HEAD") || (emp.EmpRole == "EMPLOYEE" && emp.EmpDisplayRole == "HEAD")); ViewData["all"] = all; ViewData["permanentHead"] = permanentHead; ViewData["requisitionsToProcess"] = requisitions; ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult ViewPastRequisitions(string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long deptId = emp.DeptId; List <Requisition> requisitions = RequisitionService.DisplayPastRequisitions(deptId); requisitions.Sort((x, y) => DateTime.Compare(y.DateOfRequest, x.DateOfRequest)); bool all = DelegateService.CheckPreviousHeadForNav(deptId); bool permanentHead = ((emp.EmpRole == "HEAD" && emp.EmpDisplayRole == "HEAD") || (emp.EmpRole == "EMPLOYEE" && emp.EmpDisplayRole == "HEAD")); ViewData["all"] = all; ViewData["permanentHead"] = permanentHead; ViewData["pastRequisitions"] = requisitions; ViewData["sessionId"] = sessionId; return(View()); }
public ActionResult GetRequisitionDetails(long reqId, string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); Requisition req = RequisitionService.GetReqByReqId(reqId); List <RequisitionDetails> requisitionDetails = RequisitionService.DisplayRequisitionDetailsByReqId(reqId); string roleForDetail = RequisitionService.FindRoleForDetail(emp); ViewData["havReq"] = RequisitionService.HavingRequisition(emp.EmpId); ViewData["roleForDetail"] = roleForDetail; ViewData["sessionId"] = sessionId; ViewData["isRep"] = (emp.EmpRole == "REPRESENTATIVE"); ViewData["requisitionDetails"] = requisitionDetails; ViewData["req"] = req; bool all = DelegateService.CheckPreviousHeadForNav(emp.DeptId); bool permanentHead = ((emp.EmpRole == "HEAD" && emp.EmpDisplayRole == "HEAD") || (emp.EmpRole == "EMPLOYEE" && emp.EmpDisplayRole == "HEAD")); ViewData["all"] = all; ViewData["permanentHead"] = permanentHead; return(View()); }
public ActionResult ViewDelegate(Models.Delegate d, string delegatedhead, string sessionId) { Employee emp = EmployeeService.GetUserBySessionId(sessionId); long deptId = emp.DeptId; List <Employee> employees = RepresentativeService.GetEmployeesByDepartment(deptId); long headId = DepartmentService.GetCurrentHead(deptId); Employee e = EmployeeDAO.GetEmployeeById(headId); ViewData["currentHead"] = e; ViewData["employees"] = employees; ViewData["timeErr"] = false; bool all = DelegateService.CheckPreviousHeadForNav(deptId); ViewData["all"] = all; ViewData["sessionId"] = sessionId; if (delegatedhead == null && d.Employee == null) { if (DelegateService.CheckDelegatedByDept(deptId)) { ViewData["delegated"] = true; } else { ViewData["delegated"] = false; } return(View()); } else if (delegatedhead == null && d.Employee != null) { d.Department = new Department(); d.Department.DeptId = deptId; bool isThereDelegate = DelegateService.CheckDelegatedByDept(deptId); bool timeErr = (d.FromDate < DateTime.Now && d.ToDate < DateTime.Now); ViewData["timeErr"] = timeErr; if (!isThereDelegate && !timeErr) { DelegateService.AddNewDelegate(d, headId); EmailNotification notice = new EmailNotification(); Employee MailReceiver = EmployeeService.GetEmployeeById(d.Employee.EmpId); notice.ReceiverMailAddress = MailReceiver.Email; notice.From = d.FromDate; notice.To = d.ToDate; Task.Run(() => emailService.SendMail(notice, EmailTrigger.ON_DELEGATED_AS_DEPT_HEAD)); } bool allnav = DelegateService.CheckPreviousHeadForNav(deptId); ViewData["all"] = allnav; long head = DepartmentService.GetCurrentHead(deptId); Employee h = EmployeeDAO.GetEmployeeById(head); ViewData["currentHead"] = h; if (timeErr) { ViewData["delegated"] = false; } else { ViewData["delegated"] = true; } return(View()); } else if (delegatedhead != null && d.Employee == null) { EmailNotification notice = new EmailNotification(); long head = DepartmentService.GetCurrentHead(deptId); Employee MailReceiver = EmployeeDAO.GetEmployeeById(head); notice.ReceiverMailAddress = MailReceiver.Email; DelegateService.DelegateToPreviousHead(deptId); Task.Run(() => emailService.SendMail(notice, EmailTrigger.ON_REMOVED_DEPT_HEAD)); List <Employee> emps = RepresentativeService.GetEmployeesByDepartment(deptId); ViewData["employees"] = emps; ViewData["delegated"] = false; bool show = DelegateService.CheckPreviousHeadForNav(deptId); ViewData["all"] = show; return(View()); } else { ViewData["delegated"] = false; return(View()); } }