using AnalyticsBLL.Warehouse; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; namespace AnalyticsSL.EndPoints.Warehouse { public class GetFactDimensions : BaseEndpoint> { private readonly IWarehouseFactDimensionBLL _bll; public GetFactDimensions(IWarehouseFactDimensionBLL bll) => _bll = bll; public override void Configure() { Get("/Warehouse/GetFactDimensions"); AllowAnonymous(); } public record GetFactDimensionsParameters( [property: FromHeader] string Login, [property: QueryParam] int FactId ); protected override string? GetCacheKey(GetFactDimensionsParameters req, LoginDTO login) => null; // admin data — not cached; dimensions change infrequently but need to be live protected override async Task> ExecuteAsync( GetFactDimensionsParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetByFactAsync(req.FactId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, GB5Shared.GB5Constant.Constant.CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, GB5Shared.GB5Constant.Constant.CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }