Esempio n. 1
0
        public async Task <IResponse <IList <LeaveApplicationDTO> > > Handle(GetEmployeeLeaveToApproveQuery request, CancellationToken cancellationToken)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(request.EmployeeCode))
                {
                    var employee = await _employeeRepo.GetEmployeeByEmpCode(request.EmployeeCode);

                    if (employee == null)
                    {
                        return(Response <IList <LeaveApplicationDTO> > .CreateFail("Employee not found"));
                    }
                    var leaveApplications = await _repo.GetEmployeeApplications(employee.Id, LeaveStatus.InProgress);

                    return(Response <IList <LeaveApplicationDTO> > .CreateSuccess(leaveApplications));
                }
                return(Response <IList <LeaveApplicationDTO> > .CreateFail("Invalid Request EmpCode is required"));
            }
            catch (Exception ex)
            {
                return(Response <IList <LeaveApplicationDTO> > .CreateFail(ex.Message));
            }
        }
 public async Task <IResponse <IList <LeaveApplicationDTO> > > GetLeaveToApprove([FromBody] GetEmployeeLeaveToApproveQuery query)
 => await _mediator.Send(query);