using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.PartnerTerm; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerBundle { public class GetTerminologyBundle : BaseEndpoint> { private readonly IPartnerTermBLL _partnerTermBLL; public GetTerminologyBundle(IPartnerTermBLL partnerTermBLL) => _partnerTermBLL = partnerTermBLL; public override void Configure() { Get("/PartnerBundle/GetTerminologyBundle"); AllowAnonymous(); } public record GetTerminologyBundleParameters( [property: FromHeader] string Login ); protected override string? GetCacheKey(GetTerminologyBundleParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(loginDTO.ClientId, EntityConstant.OBJECTTERMINOLOGYBUNDLE, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync( GetTerminologyBundleParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _partnerTermBLL.GetTerminologyBundle(loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }