using FastEndpoints; using FrameworkBLL.ActionPanel; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.ActionPanel { // Replaces config/admin.json as the source of truth for GbFormActionComponent/gbgrid/ // reportviewer (Phase 2 of the Command Palette/Action Panel/Quick Action effort) — resolves // both MACTIONPANEL rows and MQUICKACTION rows for one screen in a single call. public class GetActionsForScreen : BaseEndpoint { private readonly IActionPanelBLL _actionPanelBLL; public GetActionsForScreen(IActionPanelBLL actionPanelBLL) { _actionPanelBLL = actionPanelBLL; } public override void Configure() { Get("/ActionPanel/GetActionsForScreen"); AllowAnonymous(); } public record GetActionsForScreenParameters( [property: QueryParam] int MenuId, [property: QueryParam] string? Channel, [property: FromHeader] string Login); protected override async Task> ExecuteAsync(GetActionsForScreenParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _actionPanelBLL.GetActionsForScreen(req.MenuId, req.Channel, loginDTO, ct); 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); } } } }