using CMSBLL.ContentType; 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.ContentTypeType { public class GetContentType : BaseEndpoint { private readonly IContentTypeBLL _ContentTypeBLL; public GetContentType(IContentTypeBLL ContentTypeBLL) { _ContentTypeBLL = ContentTypeBLL; } public override void Configure() { Get("/ContentType/GetContentType"); AllowAnonymous(); } public record GetContentTypeParameters( [property: QueryParam] int ContentTypeId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetContentTypeParameters GetContentTypeParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(GetContentTypeParameters.ContentTypeId!, EntityConstant.OBJECTContentType, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetContentTypeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ContentTypeBLL.GetContentType(req.ContentTypeId, 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); } } } }