using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Adjustment; using PayrollDAL.DTO.Adjustment; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Adjustment { public class SaveAdjustment : BaseEndpoint> { private readonly IAdjustmentBLL _AdjustmentBLL; public SaveAdjustment(IAdjustmentBLL adjustmentBLL) { _AdjustmentBLL = adjustmentBLL; } public override void Configure() { Post("/Adjustment/SaveAdjustment"); AllowAnonymous(); } public record SaveAdjustmentParameters( [property: FromHeader] string Login, [property: FromBody] AdjustmentDTO AdjustmentDTO ); protected override async Task> ExecuteAsync(SaveAdjustmentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AdjustmentBLL.SaveAdjustment(req.AdjustmentDTO, LoginDTO!, ct); 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); } } } }