using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.EmiChangeRequest; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.EmiChangeRequest { public class DeleteEmiChangeRequest : BaseEndpoint> { private readonly IEmiChangeRequestBLL _EmiChangeRequestBLL; public DeleteEmiChangeRequest(IEmiChangeRequestBLL emiChangeRequestBLL) { _EmiChangeRequestBLL = emiChangeRequestBLL; } public override void Configure() { Delete("/EmiChangeRequest/DeleteEmiChangeRequest"); AllowAnonymous(); } public record DeleteEmiChangeRequestParameters( [property: FromHeader] string Login, [property: QueryParam] int EmiChangeRequestId ); protected override async Task> ExecuteAsync( DeleteEmiChangeRequestParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _EmiChangeRequestBLL.DeleteEmiChangeRequest(req.EmiChangeRequestId, 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); } } } }