using FastEndpoints; using FrameworkBLL.EventSource; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.EventSource { public class DeleteEventSource : BaseEndpoint> { public readonly IEventSourceBLL _EventSourceBLL; public DeleteEventSource(IEventSourceBLL IEventSourceBLL) { _EventSourceBLL = IEventSourceBLL; } public override void Configure() { Delete("/EventSource/DeleteEventSource"); AllowAnonymous(); } public record DeleteEventSourceParameters( [property: FromHeader] string Login, [property: QueryParam] int EventSourceId ); protected override async Task> ExecuteAsync(DeleteEventSourceParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _EventSourceBLL.DeleteEventSource(req.EventSourceId, 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); } } } }