//GetCategoriesForCategoriesPage public string GetCategoriesForCategoriesPage(long eventID, bool onlyLeafs) { List <IGrouping <int, spCategory_View_CategoriesForEventResult> > rootCategories = dataContext.spCategory_View_CategoriesForEvent(eventID, null, false).GroupBy(Q => Q.MainCategory_ID).ToList(); if (!rootCategories.Any()) { return(String.Empty); } List <IdTitleCount> tags = dataContext.spGetTagsForEvent(eventID, false).Select(t => new IdTitleCount { ID = t.ID, Title = t.Title, Count = t.AuctionCount.GetValueOrDefault(0) }).ToList(); StringBuilder sb = new StringBuilder(); int A; List <spCategory_View_CategoriesForEventResult> list; if (onlyLeafs) { sb.Append("<div><table style=\"table-layout:fixed\"><colgroup><col width=\"375px\" /><col width=\"375px\" /></colgroup>"); } foreach (IGrouping <int, spCategory_View_CategoriesForEventResult> category in rootCategories) { list = category.ToList(); A = (int)Math.Ceiling(list.Count * 0.5); if (!onlyLeafs) { sb.AppendFormat("<div><u><a href='/Auction/CategoryView/{0}/{1}/{2}' title='' class = \"RootCatLink\">{3}</a></u>", list[0].EventCategory_ID, UrlParser.TitleToUrl(list[0].MainCategoryTitle), UrlParser.TitleToUrl(list[0].CategoryTitle), list[0].MainCategoryTitle); sb.Append("<table style=\"table-layout:fixed\"><colgroup><col width=\"375px\" /><col width=\"375px\" /></colgroup>"); } for (int i = 0; i < A; i++) { sb.Append("<tr><td>"); sb.AppendFormat("<a href='/Auction/CategoryView/{0}/{1}/{2}/{3}' title='' class=\"SubCatLink\" >{4}</a>", list[i].EventCategory_ID, UrlParser.TitleToUrl(list[i].EventTitle), UrlParser.TitleToUrl(list[i].MainCategoryTitle), UrlParser.TitleToUrl(list[i].CategoryTitle), list[i].CategoryTitle + " <span class=\"auctionCount\">(" + list[i].AuctionCount + ")</span>"); sb.Append("</td><td>"); if (i + A < list.Count) { sb.AppendFormat("<a href='/Auction/CategoryView/{0}/{1}/{2}/{3}' title='' class=\"SubCatLink\" >{4}</a>", list[i + A].EventCategory_ID, UrlParser.TitleToUrl(list[i + A].EventTitle), UrlParser.TitleToUrl(list[i + A].MainCategoryTitle), UrlParser.TitleToUrl(list[i + A].CategoryTitle), list[i + A].CategoryTitle + " <span class=\"auctionCount\">(" + list[i + A].AuctionCount + ")</span>"); } else { sb.Append(" "); } sb.Append("</td></tr>"); } if (!onlyLeafs) { sb.Append("</table></div>"); } } if (!onlyLeafs) { foreach (var tag in tags) { sb.AppendFormat("<a class='SubCatLink' href='/Auction/Tcategory/{0}/{2}'>{1}</a>", tag.ID, tag.Title, UrlParser.TitleToUrl(tag.Title)); } } else { foreach (var tag in tags) { sb.Append("<tr><td>"); sb.AppendFormat("<a class='SubCatLink' href='/Auction/Tcategory/{0}/{3}'>{1} ({2})</a>", tag.ID, tag.Title, tag.Count, UrlParser.TitleToUrl(tag.Title)); sb.Append("</td></tr>"); } } if (onlyLeafs) { sb.Append("</table></div>"); } return(sb.ToString()); }