using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.NDTCertificate; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.NDTCertificate { public class DeleteNDTCertificate : BaseEndpoint> { private readonly INDTCertificateBLL _NDTCertificateBLL; public DeleteNDTCertificate(INDTCertificateBLL NDTCertificateBLL) { _NDTCertificateBLL = NDTCertificateBLL; } public override void Configure() { Delete("/NDTCertificate/DeleteNDTCertificate"); AllowAnonymous(); } public record DeleteNDTCertificateParameters( [property: FromHeader] string Login, [property: QueryParam] int NDTCertificateId ); protected override async Task> ExecuteAsync(DeleteNDTCertificateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _NDTCertificateBLL.DeleteNDTCertificate(req.NDTCertificateId, 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); } } } }