using FastEndpoints; using FrameworkBLL.CommandPanel; 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.CommandPanel { public class GetCommandPanel : BaseEndpoint { private readonly ICommandPanelBLL _commandPanelBLL; public GetCommandPanel(ICommandPanelBLL commandPanelBLL) { _commandPanelBLL = commandPanelBLL; } public override void Configure() { Get("/CommandPanel/GetCommandPanel"); AllowAnonymous(); } public record GetCommandPanelParameters([property: QueryParam] int CommandId, [property: FromHeader] string Login); protected override async Task> ExecuteAsync(GetCommandPanelParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _commandPanelBLL.GetCommandPanel(req.CommandId, 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); } } } }