using FastEndpoints; using FrameworkBLL.ActionRunMonitor; 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.ActionRunMonitor { public class GetActionRunByCorrelation : BaseEndpoint> { private readonly IActionRunMonitorBLL _bll; public GetActionRunByCorrelation(IActionRunMonitorBLL bll) => _bll = bll; public override void Configure() { Get("/ActionRun/GetActionRunByCorrelation"); 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); } } } }