public async Task <ActionResult> SubmitRequest(List <AdminRequestViewModel> viewModel, bool CheckForApproval) { var approver = new EmployeeService().RetrieveEmployeeById(viewModel.Select(x => x.Approver.EmployeeID).FirstOrDefault()); AdminRequestViewModel adminModel = new AdminRequestViewModel { RequestId = viewModel.Select(x => x.RequestId).FirstOrDefault(), Employee = viewModel.Select(x => x.Employee).FirstOrDefault(), Approver = new Employee { EmployeeID = viewModel.Select(x => x.Approver.EmployeeID).FirstOrDefault(), }, PTOComment = viewModel.Select(x => x.PTOComment).FirstOrDefault(), Status = viewModel.Select(x => x.Status).FirstOrDefault(), StatusChangeComment = viewModel.Select(x => x.StatusChangeComment).FirstOrDefault(), }; if (CheckForApproval == true && ModelState.IsValid) { new RequestService().UpdateRequest(adminModel.RequestId, approver.ApproverEmployeeId, adminModel.PTOComment, RequestStatus.Approved, adminModel.StatusChangeComment, DateTime.Now); await SendApprovedEmailToEmployee(adminModel.Employee.Email); } return(RedirectToAction("RequestList")); }
public async Task <ActionResult> DeclineRequest(long requestID, long approverId, string comment, string requestChangeComment, string email) { AdminRequestViewModel viewModel = new AdminRequestViewModel { RequestId = requestID, Employee = new Employee { ApproverEmployeeId = approverId, Email = email }, PTOComment = comment, StatusChangeComment = requestChangeComment, }; if (ModelState.IsValid) { new RequestService().UpdateRequest(viewModel.RequestId, viewModel.Employee.ApproverEmployeeId, viewModel.PTOComment, RequestStatus.Declined, viewModel.StatusChangeComment, DateTime.Now); await SendDeclinedEmailToEmployee(email); return(RedirectToAction("RequestList")); } else { return(RedirectToAction("RequestList")); } }
public ActionResult InspectEmployee(long EmployeesId, long RequestId) { var approvers = new AdminService().RetrieveApprovers(); Employee employee = new EmployeeService().RetrieveEmployeeById(EmployeesId); var retrieveRollover = new EmployeeService().RetrieveRolloverForEmployee(EmployeesId); var ptoModel = new PTOViewModel { RolloverHours = retrieveRollover.Hours }; var request = new RequestService().RetrieveRequestListById(RequestId); var viewmodel = new AdminRequestViewModel { Employee = employee, Approver = new EmployeeService().RetrieveEmployeeById(approvers.First(a => a.ApproverID == request.ApproverEmployeeID).EmployeeID.Value), RequestDays = request.RequestDays, PTOComment = request.PTOComment, Status = request.Status, RequestId = request.PTORequestId, RequestDate = request.RequestDate, User = new UserViewModel { HireDate = employee.HireDate, PTO = ptoModel, UserID = employee.EmployeeID } }; // Calculate PTORate and PTOHours and Anniversary CalculatePTO(viewmodel.User); return(View("~/Views/Admin/_Inspect.cshtml", viewmodel)); }