using FastEndpoints; 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 GetAdjustment : BaseEndpoint> { private readonly IAdjustmentBLL _AdjustmentBLL; public GetAdjustment(IAdjustmentBLL adjustmentBLL) { _AdjustmentBLL = adjustmentBLL; } public override void Configure() { Get("/Adjustment/GetAdjustment"); AllowAnonymous(); } public record GetAdjustmentParameters( [property: FromHeader] string Login, [property: QueryParam] int AdjustmentId ); protected override async Task> ExecuteAsync(GetAdjustmentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AdjustmentBLL.GetAdjustment(req.AdjustmentId, 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); } } } }