using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.TLeave; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.TLeave { public class DeleteTLeave : BaseEndpoint> { private readonly ITLeaveBLL _TLeaveBLL; public DeleteTLeave(ITLeaveBLL tLeaveBLL) => _TLeaveBLL = tLeaveBLL; public override void Configure() { Delete("/TLeave/DeleteTLeave"); AllowAnonymous(); } /// /// TLeaveId — the leave record to delete/cancel. /// CancelApplicable — 0 = hard delete (pending leaves only); /// 1 = soft cancel, sets STATUS = 2 so the /// leave balance is automatically reverted. /// public record DeleteTLeaveParameters( [property: QueryParam] int TLeaveId, [property: QueryParam] int CancelApplicable, [property: FromHeader] string Login ); protected override string? GetCacheKey(DeleteTLeaveParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( DeleteTLeaveParameters req, LoginDTO loginDTO, CancellationToken ct) { var result = await _TLeaveBLL.DeleteTLeave(req.TLeaveId, req.CancelApplicable, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } } }