public BaseResponse <ProductListDto> QueryList(ProductListQueryDto query) { var queriable = _productRepository.QueryAll(); var categoryTreeIds = GetChildBranches(query.CategoryId); var total = _productRepository.Count(p => categoryTreeIds.Contains(p.CategoryId) || p.CategoryId == query.CategoryId); if (!string.IsNullOrEmpty(query.Sort?.Column)) { if (query.Sort.IsAsc) { queriable = queriable.OrderBy(query.Sort.Column); } else { queriable = queriable.OrderBy(query.Sort.Column + " descending"); } } var list = queriable.Where(p => categoryTreeIds.Contains(p.CategoryId) || p.CategoryId == query.CategoryId) .Skip(query.Skip).Take(query.Take).Select(e => _mapper.Map <ProductViewDto>(e)).ToList(); return(new SuccessResponse <ProductListDto>(new ProductListDto() { List = list, TotalElements = total })); }
public BaseResponse <ProductListDto> QueryList([FromBody] ProductListQueryDto query) { return(_productService.QueryList(query)); }