using FastEndpoints; using FrameworkBLL.DashboardPage; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.DashboardPage { public class GetDashboardPage : BaseEndpoint> { private readonly IDashboardPageBLL _DashboardPageBLL; public GetDashboardPage(IDashboardPageBLL DashboardPageBLL) { _DashboardPageBLL = DashboardPageBLL; } public override void Configure() { Get("/DashboardPage/GetDashboardPage"); AllowAnonymous(); } public record GetDashboardPageParameters( [property: FromHeader] string Login, [property: QueryParam] int DashboardId ); protected override string? GetCacheKey(GetDashboardPageParameters Parameters, LoginDTO LoginDTO) => KeyGenerator.KeyGeneration(Parameters.DashboardId, EntityConstant.OBJECTDASHBOARDPAGE, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); protected override async Task> ExecuteAsync(GetDashboardPageParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _DashboardPageBLL.GetDashboardPage(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); } } } }