//GetCategoriesMenuByEvent public string GetCategoriesMenuByEvent(long? eventID, bool onlyLeafs) { Event evnt; EventRepository er = new EventRepository(dataContext, CacheRepository); if (!eventID.HasValue) { evnt = er.GetCurrent(); eventID = evnt.ID; } else { evnt = er.GetEventByID(eventID.Value); } if (evnt.Type_ID == (int)Consts.EventTypes.Sales) { return string.Format("<a id='aCurrentSales' href='/Sales' title=''>CURRENT SALES</a>"); } List<IGrouping<int, spCategory_View_CategoriesForEventResult>> rootCategories = dataContext.spCategory_View_CategoriesForEvent(eventID, null, false).GroupBy(Q => Q.MainCategory_ID).ToList(); List<IdTitle> tags = dataContext.spGetTagsForEvent(eventID, false).Select(t => new IdTitle { ID = t.ID, Title = t.Title }).ToList(); if (!rootCategories.Any()) return String.Empty; StringBuilder sb = new StringBuilder(); List<spCategory_View_CategoriesForEventResult> list; int A, count = 0; bool oneMainCategory = rootCategories.Count == 1; sb.AppendFormat("<a id='aCurrentAuction' {0} href='/Auction/Category' title=''><div class='drop_down'>CURRENT AUCTION</div></a><ul id='categories_menu'>", oneMainCategory || onlyLeafs ? "class='oneMainCategory'" : string.Empty); if (onlyLeafs) { sb.Append("<li>"); sb.Append("<table cellpadding=\"0\" cellspacing=\"0\"><colgroup><col width=\"400px\" /><col width=\"400px\" /></colgroup>"); } foreach (IGrouping<int, spCategory_View_CategoriesForEventResult> category in rootCategories) { list = category.ToList(); A = (int)Math.Ceiling(list.Count * 0.5); if (!onlyLeafs) { sb.Append("<li>"); if (!oneMainCategory) sb.AppendFormat("<a href='/Auction/CategoryView/{0}/{1}/{2}' title=''>{3} <em> </em></a>", list[0].EventCategory_ID, UrlParser.TitleToUrl(list[0].EventTitle), UrlParser.TitleToUrl(list[0].MainCategoryTitle), list[0].MainCategoryTitle); sb.AppendFormat("<table cellpadding=\"0\" cellspacing=\"0\"><colgroup><col width=\"400px\" />{0}</colgroup>", (list.Count > 2) ? "<col width=\"400px\" />" : "<col width=\"1px\" />"); } for (int i = 0; i < A; i++) { sb.Append("<tr><td>"); sb.AppendFormat("<a href='/Auction/CategoryView/{0}/{1}/{2}/{3}' title=''>{4}</a>", list[i].EventCategory_ID, UrlParser.TitleToUrl(list[i].EventTitle), UrlParser.TitleToUrl(list[i].MainCategoryTitle), UrlParser.TitleToUrl(list[i].CategoryTitle), list[i].CategoryTitle + " [" + list[i].AuctionCount + "]"); sb.Append("</td><td>"); if (i + A < list.Count) { sb.AppendFormat("<a href='/Auction/CategoryView/{0}/{1}/{2}/{3}' title=''>{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 + " [" + list[i + A].AuctionCount + "]"); } else sb.Append(" "); sb.Append("</td></tr>"); } if (!onlyLeafs) { sb.Append("</table></li>"); } count++; if (!onlyLeafs && count < rootCategories.Count()) sb.Append("<li><hr /></li>"); } if (!onlyLeafs) { foreach (var tag in tags) { sb.AppendFormat("<li><a href='/Auction/Tcategory/{0}/{2}'>{1}</a></li>", tag.ID, tag.Title, UrlParser.TitleToUrl(tag.Title)); } } else { foreach (var tag in tags) { sb.Append("<tr><td>"); sb.AppendFormat("<li><a href='/Auction/Tcategory/{0}/{2}'>{1}</a></li>", tag.ID, tag.Title, UrlParser.TitleToUrl(tag.Title)); sb.Append("</td></tr>"); } } if (onlyLeafs) { sb.Append("</table></li>"); } sb.Append("</ul>"); return sb.ToString(); }
//GetCategoriesTreeByEvent public string GetCategoriesTreeByEvent(long? event_id) { if (!event_id.HasValue) { EventRepository er = new EventRepository(dataContext, CacheRepository); event_id = er.GetCurrent().ID; } List<IGrouping<int, spCategory_View_CategoriesForEventResult>> rootCategories = dataContext.spCategory_View_CategoriesForEvent(event_id, null, false).GroupBy(Q => Q.MainCategory_ID).ToList(); if (rootCategories.Count() == 0) return String.Empty; StringBuilder sb = new StringBuilder(); sb.AppendLine("<ol class='category_list_main'><li class='category_list_header_container'><div class='category_list_header'>" + rootCategories[0].FirstOrDefault().EventTitle + "</div></li>"); spCategory_View_CategoriesForEventResult item; List<spCategory_View_CategoriesForEventResult> list; foreach (IGrouping<int, spCategory_View_CategoriesForEventResult> category in rootCategories) { item = category.FirstOrDefault(); sb.AppendFormat("<li><div class='category_list_head' id='dv{0}'><img id='imgCollapse' src='{2}' /><img id='imgExpand' src='{3}' style='display:none' /> {1}</div>", item.MainCategory_ID, item.MainCategoryTitle, AppHelper.CompressImage("arrow_collapse.png"), AppHelper.CompressImage("arrow_expand.png")); list = category.ToList(); sb.AppendLine("<div class='category_list_body'><ul>"); foreach (spCategory_View_CategoriesForEventResult ec in list) { sb.AppendLine("<li>"); sb.AppendFormat("<a href='/Auction/CategoryView/{0}/{1}/{2}/{3}'>{4}</a> <font>[{5}]</font>", ec.EventCategory_ID, UrlParser.TitleToUrl(ec.EventTitle), UrlParser.TitleToUrl(ec.MainCategoryTitle), UrlParser.TitleToUrl(ec.CategoryTitle), ec.CategoryTitle, ec.AuctionCount); sb.AppendLine("</li>"); } sb.AppendLine("</ul></div>"); sb.AppendLine("</li>"); } sb.AppendLine("<li class='category_list_footer'> </li>"); sb.AppendLine("</ol>"); return sb.ToString(); }