using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.TRMEmployee; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.TRMEmployee { public class GetTRMEmployee : BaseEndpoint> { private readonly ITRMEmployeeBLL _TRMEmployeeBLL; public GetTRMEmployee(ITRMEmployeeBLL trmEmployeeBLL) { _TRMEmployeeBLL = trmEmployeeBLL; } public override void Configure() { Get("/TRMEmployee/GetTRMEmployee"); AllowAnonymous(); } public record GetTRMEmployeeParameters( [property: QueryParam] int EmployeeId, [property: QueryParam] string LanguageId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetTRMEmployeeParameters parameters, LoginDTO loginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(parameters.TRMEmployeeId!, EntityConstant.OBJECTTRMEMployee, CacheKeyLevel.USER_LEVEL, loginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetTRMEmployeeParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TRMEmployeeBLL.GetTRMEmployee(req.EmployeeId,req.LanguageId, loginDTO!); 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); } } } }