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 TLeavePostingProcess : BaseEndpoint> { private readonly ITLeaveBLL _TLeaveBLL; public TLeavePostingProcess(ITLeaveBLL tLeaveBLL) { _TLeaveBLL = tLeaveBLL; } public override void Configure() { Post("/TLeave/TLeavePostingProcess"); AllowAnonymous(); } public record TLeavePostingProcessParameters( [property: FromHeader] string Login, [property: FromBody] TLeaveDTO TLeaveDTO ); protected override string? GetCacheKey(TLeavePostingProcessParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( TLeavePostingProcessParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _TLeaveBLL.TLeavePostingProcess(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); } } } }