using FastEndpoints; using FrameworkBLL.Formula; using FrameworkDAL.DTO.Formula; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Formula { public class SaveFormula : BaseEndpoint> { private readonly IFormulaBLL _FormulaBLL; public SaveFormula(IFormulaBLL FormulaBLL) { _FormulaBLL = FormulaBLL; } public override void Configure() { Post("/Formula/SaveFormula"); AllowAnonymous(); } public record SaveFormulaParameters( [property: FromHeader] string Login, [property: FromBody] FormulaDTO FormulaDTO ); protected override async Task> ExecuteAsync(SaveFormulaParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _FormulaBLL.SaveFormula(req.FormulaDTO, 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); } } } }