using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using FrameworkBLL.TRMAddress; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.TRMAddress { public class GetTRMAddress : BaseEndpoint> { private readonly ITRMAddressBLL _TRMAddressBLL; public GetTRMAddress(ITRMAddressBLL trmAddressBLL) { _TRMAddressBLL = trmAddressBLL; } public override void Configure() { Get("/TRMAddress/GetTRMAddress"); AllowAnonymous(); } public record GetTRMAddressParameters( [property: QueryParam] int AddressId, [property: QueryParam] string LanguageId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetTRMAddressParameters parameters, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(parameters.AddressId!, EntityConstant.OBJECTADDRESS, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetTRMAddressParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TRMAddressBLL.GetTRMAddress(req.AddressId, 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 ); } } } }