using FastEndpoints; using FrameworkBLL.EventChannel; using FrameworkDAL.DTO.EventChannel; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.EventChannel { public class SaveEventChannel : BaseEndpoint> { private readonly IEventChannelBLL _EventChannelBLL; public SaveEventChannel(IEventChannelBLL EventChannelBLL) { _EventChannelBLL = EventChannelBLL; } public override void Configure() { Post("/EventChannel/SaveEventChannel"); AllowAnonymous(); } public record SaveEventChannelParameters( [property: FromHeader] string Login, [property: FromBody] EventChannelDTO EventChannelDTO ); protected override async Task> ExecuteAsync(SaveEventChannelParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _EventChannelBLL.SaveEventChannel(req.EventChannelDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.UserLevel, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.UserLevel, LoginDTO, ex.Message, 500); } } } }