using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Adjustment; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Adjustment { public class GetAdjustmentForImport : BaseEndpoint> { private readonly IAdjustmentBLL _AdjustmentBLL; public GetAdjustmentForImport(IAdjustmentBLL adjustmentBLL) { _AdjustmentBLL = adjustmentBLL; } public override void Configure() { Post("/Adjustment/GetAdjustmentForImport"); AllowAnonymous(); } public record GetAdjustmentForImportParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync(GetAdjustmentForImportParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AdjustmentBLL.GetAdjustmentForImport(req.CriteriaDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }