using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Relieving; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Relieving { public class GetRelieving : BaseEndpoint> { private readonly IRelievingBLL _RelievingBLL; public GetRelieving(IRelievingBLL relievingBLL) { _RelievingBLL = relievingBLL; } public override void Configure() { Get("/Relieving/GetRelieving"); AllowAnonymous(); } public record GetRelievingParameters( [property: FromHeader] string Login, [property: QueryParam] int RelievingId ); protected override async Task> ExecuteAsync( GetRelievingParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _RelievingBLL.GetRelieving(req.RelievingId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500); } } } }