using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayrollDAL.DTO.AdditionDeductionDetail; using PayRollBLL.AdditionDeductionDetail; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.AdditionDeductionDetail { public class SaveAdditionDeductionDetail : BaseEndpoint> { private readonly IAdditionDeductionDetailBLL _additionDeductionDetailBLL; public SaveAdditionDeductionDetail(IAdditionDeductionDetailBLL additionDeductionDetailBLL) { _additionDeductionDetailBLL = additionDeductionDetailBLL; } public override void Configure() { Post("/AdditionDeductionDetail/SaveAdditionDeductionDetail"); AllowAnonymous(); } public record SaveAdditionDeductionDetailParameters([property: FromHeader] string Login, [property: FromBody] AdditionDeductionDetailDTO AdditionDeductionDetailDTO); protected override async Task> ExecuteAsync(SaveAdditionDeductionDetailParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _additionDeductionDetailBLL.SaveAdditionDeductionDetail(req.AdditionDeductionDetailDTO, 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); } } } }