using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.GateEntry; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.GateEntry { public class GetGateEntry : BaseEndpoint> { private readonly IGateEntryBLL _GateEntryBLL; public GetGateEntry(IGateEntryBLL gateEntryBLL) { _GateEntryBLL = gateEntryBLL; } public override void Configure() { Get("/GateEntry/GetGateEntry"); AllowAnonymous(); } public record GetGateEntryParameters( [property: FromHeader] string Login, [property: QueryParam] int GateEntryId ); //protected override string? GetCacheKey(GetGateEntryParameters req, LoginDTO loginDTO) //{ // try // { // return KeyGenerator.KeyGeneration( // req.GateEntryId, // EntityConstant.OBJECTGATEENTRY, // CacheKeyLevel.USER_LEVEL, // loginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync( GetGateEntryParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _GateEntryBLL.GetGateEntry(req.GateEntryId, 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); } } } }