using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Employee; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Employee { public class GetEmployeeVsShiftPattern : BaseEndpoint> { private readonly IEmployeeBLL _EmployeeBLL; public GetEmployeeVsShiftPattern(IEmployeeBLL employeeBLL) { _EmployeeBLL = employeeBLL; } public override void Configure() { Post("/Employee/GetEmployeeVsShiftPattern"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync(Params req, LoginDTO LoginDTO, CancellationToken ct) { try { var (items, total) = await _EmployeeBLL.GetEmployeeVsShiftPattern(req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO, ct); var response = await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(items, CacheKeyLevel.NOT_REQUIRED, LoginDTO); response.Total = total; return response; } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }