using Dapr; using FastEndpoints; using FrameworkBLL.EventLog; using FrameworkDAL.DTO.EventLog; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.EventLog { public sealed class SaveEventLog : BaseEndpoint { private readonly IEventLogBLL _eventLogBLL; public SaveEventLog(IEventLogBLL eventLogBLL) { _eventLogBLL = eventLogBLL; } public override void Configure() { Post("/EventLog/SaveEventLog"); AllowAnonymous(); } public record SaveEventLogParameters( [property: FromBody] EventLogDTO EventLogDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveEventLogParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _eventLogBLL.SaveEventLog(req.EventLogDTO, LoginDTO!); 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); } } } }