using FastEndpoints; using FrameworkBLL.EventSource; using FrameworkDAL.DTO.Event; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.EventSource { public class SaveEventSource : BaseEndpoint> { private readonly IEventSourceBLL _EventSourceBLL; public SaveEventSource(IEventSourceBLL EventSourceBLL) { _EventSourceBLL = EventSourceBLL; } public override void Configure() { Post("/EventSource/SaveEventSource"); AllowAnonymous(); } public record SaveEventSourceParameters( [property: FromHeader] string Login, [property: FromBody] EventSourceDTO EventSourceDTO ); protected override async Task> ExecuteAsync(SaveEventSourceParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _EventSourceBLL.SaveEventSource(req.EventSourceDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NotRequired, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NotRequired, LoginDTO, ex.Message, 500); } } } }