public override string ToHtmlString() { var allPortfolios = _categoryId.HasValue ? portfolioService.GetActives(_categoryId.Value) : portfolioService.GetActives(); if (this._customPortfolioIds != null) { allPortfolios = allPortfolios.Where(s => _customPortfolioIds.Contains(s.Id)); } if (!string.IsNullOrEmpty(_searchTerm)) { allPortfolios = allPortfolios.Where(s => s.Title.Contains(_searchTerm)); } if (!string.IsNullOrEmpty(_userId)) { allPortfolios = allPortfolios.Where(s => s.UserId.Contains(_userId)); } if (_displayCount.HasValue && _displayCount.Value > 0) { allPortfolios = allPortfolios.Take(_displayCount.Value); } if (this._pageSize.HasValue) { var pageIndex = this.GetPageIndex(); this.Component.Pager = new Pager(this.HtmlHelper, this._pageSize.Value, pageIndex, allPortfolios.Count(), this._pageQueryName).ToHtmlString(); allPortfolios = allPortfolios.ToPagedList(pageIndex - 1, this._pageSize.Value); } this.Component.Items.AddRange(allPortfolios); this.Component.AllCategories = categoryService.GetActives().ToList(); return(base.ToHtmlString()); }