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