using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MarketingBLL.ContentRef; using static GB5Shared.GB5Constant.Constant; namespace MarketingSL.EndPoints.ContentRef; public class GetContentRef : BaseEndpoint> { private readonly IContentRefBLL _ContentRefBLL; public GetContentRef(IContentRefBLL contentRefBLL) => _ContentRefBLL = contentRefBLL; public override void Configure() { Get("/ContentRef/GetContentRef"); AllowAnonymous(); } public record GetContentRefParameters( [property: QueryParam] int ContentRefId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetContentRefParameters req, LoginDTO login) => KeyGenerator.KeyGeneration(req.ContentRefId, EntityConstant.OBJECTMARKETINGCONTENTREF, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync(GetContentRefParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _ContentRefBLL.GetContentRef(req.ContentRefId, login!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }