using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.PayRevision; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.Endpoints.PayRevision { public class GetPayRevisionByField : BaseEndpoint { private readonly IPayRevisionBLL _PayRevisionBLL; public GetPayRevisionByField(IPayRevisionBLL PayRevisionBLL) { _PayRevisionBLL = PayRevisionBLL; } public override void Configure() { Get("/PayRevision/GetPayRevisionByField"); AllowAnonymous(); } public record GetPayRevisionByFieldParameters( [property: QueryParam] string FieldName, [property: QueryParam] int FieldId, [property: QueryParam] int Nature, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetPayRevisionByFieldParameters parameters, LoginDTO loginDTO) //{ // try // { // return KeyGenerator.KeyGeneration( // $"{parameters.FieldName}_{parameters.FieldId}_{parameters.Nature}", // EntityConstant.OBJECTPAYREVISION, // CacheKeyLevel.CLIENT_LEVEL, // loginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync( GetPayRevisionByFieldParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _PayRevisionBLL.GetPayRevisionByField( parameters.FieldName, parameters.FieldId, parameters.Nature, loginDTO, ct); 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); } } } }