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