using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.TLeave; using PayRollDAL.DTO.TLeave; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.TLeave { public class TleavePostingMakingZero : BaseEndpoint> { private readonly ITLeaveBLL _TLeaveBLL; public TleavePostingMakingZero(ITLeaveBLL tLeaveBLL) { _TLeaveBLL = tLeaveBLL; } public override void Configure() { Post("/TLeave/TleavePostingMakingZero"); AllowAnonymous(); } public record TleavePostingMakingZeroParameters( [property: FromHeader] string Login, [property: FromBody] TLeaveDTO TLeaveDTO ); protected override string? GetCacheKey(TleavePostingMakingZeroParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( TleavePostingMakingZeroParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _TLeaveBLL.TleavePostingMakingZero(req.TLeaveDTO, 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); } } } }