using FastEndpoints; using FrameworkBLL.ActionPanel; using FrameworkDAL.DTO.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.QuickAction { public class SaveQuickAction : BaseEndpoint> { private readonly IActionPanelBLL _actionPanelBLL; public SaveQuickAction(IActionPanelBLL actionPanelBLL) { _actionPanelBLL = actionPanelBLL; } public override void Configure() { Post("/QuickAction/SaveQuickAction"); AllowAnonymous(); } public record SaveQuickActionParameters([property: FromHeader] string Login, [property: FromBody] QuickActionDTO QuickActionDTO); protected override string? GetCacheKey(SaveQuickActionParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(SaveQuickActionParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _actionPanelBLL.SaveQuickAction(req.QuickActionDTO, 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); } } } }