using FastEndpoints; using FrameworkBLL.Taxonomy; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Taxonomy.TopicLink { public class GetTopicLinksByEntity : BaseEndpoint> { private readonly ITopicLinkBLL _TopicLinkBLL; public GetTopicLinksByEntity(ITopicLinkBLL topicLinkBLL) { _TopicLinkBLL = topicLinkBLL; } public override void Configure() { Get("/TaxonomyTopicLink/GetTopicLinksByEntity"); AllowAnonymous(); } public record GetTopicLinksByEntityParameters( [property: QueryParam] int EntityType, [property: QueryParam] int EntityId, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(GetTopicLinksByEntityParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TopicLinkBLL.GetTopicLinksByEntity(req.EntityType, req.EntityId, 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); } } } }