using AdminBLL.Exchange; using AdminDAL.DTO.Currency; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.Exchange { public class SaveExchange : BaseEndpoint> { private readonly IExchangeBLL _ExchangeBLL; public SaveExchange(IExchangeBLL ExchangeBLL) { _ExchangeBLL = ExchangeBLL; } public override void Configure() { Post("/Exchange/SaveExchange"); AllowAnonymous(); } public record SaveExchangeParameters( [property: FromHeader] string Login, [property: FromBody] ExchangeDTO ExchangeDTO ); protected override async Task> ExecuteAsync(SaveExchangeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ExchangeBLL.SaveExchange(req.ExchangeDTO, 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); } } } }