using FastEndpoints; using FrameworkBLL.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 DeleteFormula : BaseEndpoint> { private readonly IFormulaBLL _FormulaBLL; public DeleteFormula(IFormulaBLL IFormulaBLL) { _FormulaBLL = IFormulaBLL; } public override void Configure() { Delete("/Formula/DeleteFormula"); AllowAnonymous(); } public record DeleteFormulaParameters( [property: FromHeader] string Login, [property: QueryParam] int FormulaId ); protected override async Task> ExecuteAsync(DeleteFormulaParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _FormulaBLL.DeleteFormula(req.FormulaId, 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); } } } }