using CMSBLL.Taxonomy; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System.Threading; using static GB5Shared.GB5Constant.Constant; namespace CMSSL.Endpoints.Taxonomy { public class GetTaxonomy : BaseEndpoint { private readonly ITaxonomyBLL _TaxonomyBLL; public GetTaxonomy(ITaxonomyBLL TaxonomyBLL) { _TaxonomyBLL = TaxonomyBLL; } public override void Configure() { Get("/Taxonomy/GetTaxonomy"); AllowAnonymous(); } public record GetTaxonomyParameters( [property: QueryParam] Guid TaxonomyId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetTaxonomyParameters GetTaxonomyParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(GetTaxonomyParameters.TaxonomyId!, EntityConstant.Taxonomy, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetTaxonomyParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _TaxonomyBLL.GetTaxonomy(parameters.TaxonomyId, 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); } } } }