public async Task <CommandResult> DepartmentApproveCommandAsync(DepartmentApproveCommand command) { var rightsRes = await CheckEmployeeRightsAsync(command.EmployeeId, EmployeeRights.CreditDepartmentChief); var employeeRes = await GetEmployeeAsync(command.EmployeeId); var requestRes = await GetCreditRequestAsync(command.CreditRequestId); var res = CheckQueries(rightsRes, employeeRes, requestRes); if (res.IsFailed) { return(new CommandResult(command, false).From(res)); } var request = requestRes.Value; request.IsCreditDepartmentApproved = command.Approved; request.CreditDepartmentComments = command.Comments; request.CreditDepartmentApproved = employeeRes.Value; var updateRes = await UpdateCreditRequestAsync(command, request); if (request.Client.User.EmailConfirmed && !updateRes.IsFailed) { await _emailService.SendRequestApprovedNotification(request.Client.User.Email); } return(updateRes); }
public ActionResult DepartmentApprove(DepartmentApproveCommand command) { var employee = GetEmployee(); command.EmployeeId = employee.Id; _employeeService.DepartmentApproveCommand(command); var request = GetRequest(command); _creditRequestService.UnassignEmployee(request); return(RedirectToAction("Department")); }