using FastEndpoints; using FrameworkBLL.Entitlement; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.FeatureDashboardMap { public class GetFeatureDashboardMap : BaseEndpoint> { private readonly IFeatureDashboardMapBLL _FeatureDashboardMapBLL; public GetFeatureDashboardMap(IFeatureDashboardMapBLL FeatureDashboardMapBLL) { _FeatureDashboardMapBLL = FeatureDashboardMapBLL; } public override void Configure() { Get("/FeatureDashboardMap/GetFeatureDashboardMap"); AllowAnonymous(); } public record GetFeatureDashboardMapParameters( [property: FromHeader] string Login, [property: QueryParam] int DashboardId ); protected override string? GetCacheKey(GetFeatureDashboardMapParameters Parameters, LoginDTO LoginDTO) => KeyGenerator.KeyGeneration(Parameters.DashboardId, EntityConstant.OBJECTFEATUREDASHBOARDMAP, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); protected override async Task> ExecuteAsync(GetFeatureDashboardMapParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _FeatureDashboardMapBLL.GetFeatureDashboardMap(req.DashboardId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }