using FastEndpoints; using FrameworkBLL.OutboxMonitor; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using System; using System.Threading; using System.Threading.Tasks; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.OutboxMonitor { public class GetOutboxByCorrelation : BaseEndpoint> { private readonly IOutboxMonitorBLL _bll; public GetOutboxByCorrelation(IOutboxMonitorBLL bll) => _bll = bll; public override void Configure() { Get("/Outbox/GetOutboxByCorrelation"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] string CorrelationKey ); protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetByCorrelationAsync(req.CorrelationKey, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.UserLevel, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, login, ex.Message, 500); } } } }