using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Goal; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Goal { public class GetSelectListGoal : BaseEndpoint> { private readonly IGoalBLL _GoalBLL; public GetSelectListGoal(IGoalBLL IGoalBLL) { _GoalBLL = IGoalBLL; } public override void Configure() { Post("/Goal/GetSelectListGoal"); AllowAnonymous(); } public record GetSelectListGoalParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async Task> ExecuteAsync( GetSelectListGoalParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _GoalBLL.GetSelectListGoal( req.FirstNumber, req.MaxResult, req.CriteriaDTO, LoginDTO!); int total = Convert.ToInt32(await _GoalBLL.GetSelectListGoal( -1, -1, req.CriteriaDTO, LoginDTO!, true)); var response = await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, 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); } } } }