using System.Text.Json; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GB5Shared.DateConverter; using PayRollBLL.TDSContact; using PayRollBLL.TDSSection; using PayRollDAL.CustomeCode.TDSSection; using PayRollSL.EndPoints.TDSContact; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.TDSSection { public class GetSelectListTDSSectionDetail : BaseEndpoint> { private readonly ITDSSectionBLL _ITDSSectionBLL; public GetSelectListTDSSectionDetail(ITDSSectionBLL ITDSSectionBLL) { _ITDSSectionBLL = ITDSSectionBLL; } public override void Configure() { Post("/TDSSection/GetSelectListTDSSectionDetail"); AllowAnonymous(); } public record GetSelectListTDSSectionDetailParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override async Task> ExecuteAsync(GetSelectListTDSSectionDetailParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ITDSSectionBLL.GetSelectListTDSSectionDetail( req.CriteriaDTO, LoginDTO!); var options = new JsonSerializerOptions { PropertyNamingPolicy = null }; options.AddGB5Converters(); // Serialize to JSON string string json = JsonSerializer.Serialize(Result, options); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(json, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }