using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GB5Shared.ListQuery; using PIEDAL.DTO.Estimation; using static GB5Shared.GB5Constant.Constant; namespace PIESL.EndPoints.Estimation { public class GetPIEEstimationRuleList : BaseEndpoint> { private readonly IListHandler _ListHandler; public GetPIEEstimationRuleList(IListHandler listHandler) { _ListHandler = listHandler; } public override void Configure() { Post("/PIE/GetPIEEstimationRuleList"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] Guid? ModuleId = null, [property: QueryParam] short? EngagementType = null, [property: QueryParam] short? ComplexityLevel = null, [property: QueryParam] bool? IsActive = null, [property: QueryParam] string? SortBy = null, [property: QueryParam] bool SortDesc = false, [property: QueryParam] int PageOffset = 0, [property: QueryParam] int PageSize = 100 ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(loginDTO.ClientId, EntityConstant.OBJECTPIEESTIMATIONRULE, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { var criteria = new PIEEstimationRuleListCriteria { ModuleId = req.ModuleId, EngagementType = req.EngagementType, ComplexityLevel = req.ComplexityLevel, IsActive = req.IsActive is null ? null : (short?)(req.IsActive.Value ? 1 : 0), SortBy = req.SortBy, SortDesc = req.SortDesc, PageOffset = req.PageOffset, PageSize = req.PageSize }; var result = await _ListHandler.HandleAsync(new PIEEstimationRuleListQuery(criteria), loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } } }