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