using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.CalculationFormula; using MMDAL.DTO.CalculationFormula; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.CalculationFormula { public class SaveCalculationFormula : BaseEndpoint> { private readonly ICalculationFormulaBLL _CalculationFormulaBLL; public SaveCalculationFormula(ICalculationFormulaBLL CalculationFormulaBLL) { _CalculationFormulaBLL = CalculationFormulaBLL; } public override void Configure() { Post("/CalculationFormula/SaveCalculationFormula"); AllowAnonymous(); } public record SaveCalculationFormulaParameters( [property: FromHeader] string Login, [property: FromBody] CalculationFormulaDTO CalculationFormulaDTO ); protected override async Task> ExecuteAsync(SaveCalculationFormulaParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _CalculationFormulaBLL.SaveCalculationFormula(req.CalculationFormulaDTO, 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); } } } }