using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Specification; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Specification { public class DeleteSpecification : BaseEndpoint> { private readonly ISpecificationBLL _SpecificationBLL; public DeleteSpecification(ISpecificationBLL SpecificationBLL) { _SpecificationBLL = SpecificationBLL; } public override void Configure() { Delete("/Specification/DeleteSpecification"); AllowAnonymous(); } public record DeleteSpecificationParameters( [property: FromHeader] string Login, [property: QueryParam] int SpecificationId ); protected override async Task> ExecuteAsync(DeleteSpecificationParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _SpecificationBLL.DeleteSpecification(req.SpecificationId, 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); } } } }