/// <summary> /// Approves the or decline leave request. /// </summary> /// <param name="requestId">The request identifier.</param> /// <param name="employeeId">The employee identifier.</param> /// <param name="approved">if set to <c>true</c> [approved].</param> /// <returns>The PendingLeave view.</returns> public ActionResult ApproveOrDeclineLeaveRequest(int requestId, int employeeId, bool approved) { var currentUserId = CurrentLoggedInUser.EmployeeId; var leaveOrchestration = Factory.CreateInstance <ILeaveOrchestration>(); var requestOutcome = leaveOrchestration.GetPendingLeaveRequests(currentUserId); var historyOutcome = leaveOrchestration.GetManagerHistory(currentUserId); var viewModel = new AwaitingApprovalViewModel { Requests = requestOutcome.Data == null ? null : requestOutcome.Data.Requests.Map(), History = historyOutcome.Data == null ? null : historyOutcome.Data.History.Map() }; var outcome = leaveOrchestration.ApproveLeave(employeeId, currentUserId, approved); if (!outcome.IsSuccessful) { ModelState.AddModelError(string.Empty, outcome.ErrorMessage); } return(View("PendingLeave", viewModel)); }
public ActionResult PendingLeave() { var currentUserId = CurrentLoggedInUser.EmployeeId; var leaveOrchestration = Factory.CreateInstance <ILeaveOrchestration>(); var masterDataOrchestration = Factory.CreateInstance <IMasterDataOrchestration>(); var outcome = leaveOrchestration.GetPendingLeaveRequests(currentUserId); var historyOutcome = leaveOrchestration.GetManagerHistory(currentUserId); if (!outcome.IsSuccessful) { ModelState.AddModelError(string.Empty, outcome.ErrorMessage); } var viewModel = new AwaitingApprovalViewModel { Requests = outcome.Data == null ? null : outcome.Data.Requests.Map(), History = historyOutcome.Data == null ? null : historyOutcome.Data.History.Map() }; return(View(viewModel)); }