using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.PayPeriod; using PayRollDAL.DTO.PayPeriod; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.PayPeriod { public class SavePayPeriod : BaseEndpoint> { private readonly IPayPeriodBLL _payPeriodBLL; public SavePayPeriod(IPayPeriodBLL IPayPeriodBLL) { _payPeriodBLL = IPayPeriodBLL; } public override void Configure() { Post("/PayPeriod/Save"); AllowAnonymous(); } public record SavePayPeriodParameters( [property: FromHeader] string Login, [property: FromBody] PayPeriodDTO PayPeriodDTO ); protected override async Task> ExecuteAsync(SavePayPeriodParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _payPeriodBLL.Save(req.PayPeriodDTO, 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 ); } } } }