using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.PayProcess; using PayRollDAL.DTO.PayProcess; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.PayProcess { // GB4 route: PayProcess.svc/All/Ou/Payprocess/ (POST) — AllOuPayProcessing(PayProcessPostDTO). // Currently returns a controlled 500 (via NotSupportedException) — see // PayProcessBLL.AllOuPayProcessing for why this is intentionally not implemented yet. public class AllOuPayProcessing : BaseEndpoint> { private readonly IPayProcessBLL _PayProcessBLL; public AllOuPayProcessing(IPayProcessBLL PayProcessBLL) { _PayProcessBLL = PayProcessBLL; } public override void Configure() { Post("/PayProcess/AllOuPayProcessing"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: FromBody] PayProcessPostDTO PayProcessPostDTO ); // Write endpoint — no GetCacheKey override; this would compute and persist real // payroll numbers and must never be served from cache. protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO loginDTO, CancellationToken ct) { try { var message = await _PayProcessBLL.AllOuPayProcessing(req.PayProcessPostDTO, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(message, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }