using CMSBLL.Content; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace CMSSL.Endpoints.Content { public class GetContent : BaseEndpoint { private readonly IContentBLL _ContentBLL; public GetContent(IContentBLL ContentBLL) { _ContentBLL = ContentBLL; } public override void Configure() { Get("/Content/GetContent"); AllowAnonymous(); } public record GetContentParameters( [property: QueryParam] int ContentId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetContentParameters GetContentParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(GetContentParameters.ContentId!, EntityConstant.OBJECTContent, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetContentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ContentBLL.GetContent(req.ContentId, 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); } } } }