public string GetLotTitleUrl(short lot, string title) { return(UrlParser.TitleToUrl(String.Format("Lot{0}~{1}", lot, title))); }
//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()); }
//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()); }
//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()); }
//GetCategoriesForCategoriesViewPage public string GetCategoriesForCategoriesByMainCategory(long event_id, int maincategory_id) { List <spCategory_View_CategoriesForEventResult> list = dataContext.spCategory_View_CategoriesForEvent(event_id, maincategory_id, false).ToList(); if (list.Count() == 0) { return(String.Empty); } StringBuilder sb = new StringBuilder(); int A; A = (int)Math.Ceiling(list.Count * 0.5); 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.ToString() + ")</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.ToString() + ")</span>"); } else { sb.Append(" "); } sb.Append("</td><td>"); } sb.Append("</table>"); return(sb.ToString()); }
private void GetParentCategoryLink(StringBuilder sb, CategoriesMap cm, bool demo) { if (cm == null || cm.CategoriesMap_Parent == null || cm.CategoriesMap_Parent.ID == cm.ID) { return; } cm = cm.CategoriesMap_Parent; sb.Insert(0, "<span> > </span>"); sb.Insert(0, String.Format("<a href='{0}/?e={2}'>{1}</a>", AppHelper.GetSiteUrl("/" + (demo?"Preview":"Auction") + "/Category/" + cm.ID + "/" + UrlParser.TitleToUrl(cm.Category.Title)), cm.Category.Title, Event_ID)); GetParentCategoryLink(sb, cm, demo); }
// GetCategoriesMapTree private object GetCategoriesMapTree(long event_id, bool demo, bool isaccessable) { List <CategoryChildLink> objCategoryChildLinkParent = new List <CategoryChildLink>(); CategoryParentChild obj = new CategoryParentChild(); List <CategoryChild> obj1 = new List <CategoryChild>(); DataCacheObject dco = (!demo) ? new DataCacheObject(DataCacheType.REFERENCE, DataCacheRegions.CATEGORIES, "GETCATEGORIESMAPTREE", new object[] { event_id, isaccessable }, CachingExpirationTime.Days_01) : new DataCacheObject(DataCacheType.REFERENCE, DataCacheRegions.CATEGORIES, "GETCATEGORIESMAPTREEPREVIEW", new object[] { event_id }, CachingExpirationTime.Days_01); object result = CacheRepository.Get(dco); if (result != null) { return(result); //new { html = result }; } List <JsTreeNode> nodesList = new List <JsTreeNode>(); JsTreeNode node, nodeParent; //event_id = 313; var map = (from EC in dataContext.EventCategories where EC.Event_ID == event_id && EC.IsActive && EC.CategoriesMap.Category.IsActive //&& EC.Auctions.Count() > 0 orderby((EC.CategoriesMap.Parent_ID.HasValue) ? EC.CategoriesMap.CategoriesMap_Parent.Category.Title : EC.CategoriesMap.Category.Title) ascending, EC.CategoriesMap.Category.Title ascending select new { CategoryMap = EC.CategoriesMap, AuctionCount = EC.Auctions.Count(), EventCategory = EC }).ToList(); Dictionary <long, JsTreeNode> tree = new Dictionary <long, JsTreeNode>(); CategoriesMap tmp; bool alreadyInTree; foreach (var c in map) { if (c.AuctionCount == 0 && c.CategoryMap.CategoriesMap_Children.Count() == 0) { continue; } tmp = c.CategoryMap; alreadyInTree = tree.ContainsKey(tmp.ID); node = (alreadyInTree) ? tree[tmp.ID] : new JsTreeNode(); node.attributes = new Attributes(); node.attributes.id = tmp.ID.ToString(); node.data = new Data(); node.data.title = tmp.Category.Title; node.data.icon = String.Empty; node.data.attributes = new Attributes(); //AppHelper.GetSiteUrl() + node.data.attributes.href = "/" + ((demo) ? "Preview" : "Auction") + "/EventCategory/" + c.EventCategory.ID.ToString() + "/" + UrlParser.TitleToUrl(c.EventCategory.FullCategory); node.data.attributes.rel = "main"; if (alreadyInTree) { continue; } tree.Add(tmp.ID, node); while (tmp.Parent_ID.HasValue) { tmp = tmp.CategoriesMap_Parent; alreadyInTree = tree.ContainsKey(tmp.ID); nodeParent = (alreadyInTree) ? tree[tmp.ID] : new JsTreeNode(); nodeParent.attributes = new Attributes(); nodeParent.attributes.id = tmp.ID.ToString(); nodeParent.data = new Data(); nodeParent.data.title = tmp.Category.Title; nodeParent.data.attributes = new Attributes(); //AppHelper.GetSiteUrl() + nodeParent.data.attributes.href = "/" + ((demo) ? "Preview" : "Auction") + "/Category/" + tmp.ID.ToString() + "/" + UrlParser.TitleToUrl(tmp.Category.Title) + "?e=" + event_id.ToString(); node.data.attributes.rel = "child"; nodeParent.data.attributes.rel = "main"; nodeParent.state = "open"; if (nodeParent.children == null) { nodeParent.children = new List <JsTreeNode>(); } nodeParent.children.Add(node); if (alreadyInTree) { break; } node = nodeParent; tree.Add(tmp.ID, nodeParent); } if (alreadyInTree) { continue; } nodesList.Add(node); } //return nodesList; StringBuilder sb = new StringBuilder(); Event evnt = dataContext.Events.SingleOrDefault(E => E.ID == event_id); CategoryChild objA1 = null; List <CategoryParentChild> lstCategoryParentChild = new List <CategoryParentChild>(); sb.Append("<ul class=\"list-unstyled\">"); foreach (JsTreeNode jstree in nodesList) { CategoryParentChild objA = new CategoryParentChild(); CategoryChildLink objCategoryChildLink = new CategoryChildLink(); List <CategoryChildLink> objCategoryChildLinkAll = new List <CategoryChildLink>(); List <CategoryChildLink> objCategoryChildLink1 = new List <CategoryChildLink>(); int uji = objA.Childs.Count; if (evnt.IsClickable || demo || evnt.IsAccessable) { objCategoryChildLink.parentLinkUrl = jstree.data.attributes.href; objCategoryChildLink.parentLinkName = jstree.data.title.ToUpper(); objA.parentLinkUrl = jstree.data.attributes.href; objA.parentLinkName = jstree.data.title.ToUpper(); sb.AppendFormat("<li ischild='{2}' class=\"title-category\" ><a href='{0}'>{1}</a> {3}", jstree.data.attributes.href, (jstree.data.attributes.rel != "main") ? jstree.data.title : jstree.data.title.ToUpper(), jstree.data.attributes.rel != "main", (!String.IsNullOrEmpty(jstree.data.icon)) ? "(" + jstree.data.icon + ")" : String.Empty, (jstree.data.attributes.rel != "main") ? " font-weight:normal;color:#0072B0;" : "font-weight:bold;color:black"); } // sb.AppendFormat("<li ischild='{2}' class=\"title-category\" ><a href='{0}'>{1}</a> {3}", jstree.data.attributes.href, (jstree.data.attributes.rel != "main") ? jstree.data.title : jstree.data.title.ToUpper(), jstree.data.attributes.rel != "main", (!String.IsNullOrEmpty(jstree.data.icon)) ? "(" + jstree.data.icon + ")" : String.Empty, (jstree.data.attributes.rel != "main") ? " font-weight:bold;color:black" : "font-weight:bold;color:black"); else { objCategoryChildLink.parentLinkUrl = jstree.data.attributes.rel; objCategoryChildLink.parentLinkName = jstree.data.title.ToUpper(); objA.parentLinkUrl = jstree.data.attributes.rel; objA.parentLinkName = jstree.data.title.ToUpper(); sb.AppendFormat("<li ischild='{1}' ><span style='{3}'>{0}</span> {2}", (jstree.data.attributes.rel != "main") ? jstree.data.title : jstree.data.title.ToUpper(), jstree.data.attributes.rel != "main", (!String.IsNullOrEmpty(jstree.data.icon)) ? "(" + jstree.data.icon + ")" : String.Empty, (jstree.data.attributes.rel != "main") ? " font-weight:normal;color:#0072B0;" : "font-weight:bold;color:black"); } //sb.AppendFormat("<li ischild='{1}' ><span style='{3}'>{0}</span> {2}", (jstree.data.attributes.rel != "main") ? jstree.data.title : jstree.data.title.ToUpper(), jstree.data.attributes.rel != "main", (!String.IsNullOrEmpty(jstree.data.icon)) ? "(" + jstree.data.icon + ")" : String.Empty, (jstree.data.attributes.rel != "main") ? " font-weight:bold;color:black;" : "font-weight:bold;color:black"); if (jstree.children != null && jstree.children.Count() > 0) { objCategoryChildLink.Parount = jstree.children.Count(); //sb.Append("<ul>"); foreach (JsTreeNode js in jstree.children) { objA1 = new CategoryChild(); GetCategoriesMapTreeChild(sb, js, evnt, demo, objCategoryChildLink, objA1); objA.Childs.Add(objA1); //objA. } objCategoryChildLinkAll.Add(objCategoryChildLink); //sb.Append("</ul>"); } sb.AppendFormat("</li>"); objCategoryChildLinkParent.Add(objCategoryChildLink); lstCategoryParentChild.Add(objA); //if (jstree.data.attributes.rel == "main") sb.Append("<li><hr /></li>"); } sb.Append("</ul>"); // IComparer<CategoryParentChild> comparer = new IComparer<CategoryParentChild>(); List <CategoryParentChild> objListOrder = lstCategoryParentChild.OrderBy(order => order.parentLinkName).ToList(); HttpContext.Current.Session["lstCategoryParentChild"] = null; HttpContext.Current.Session["lstCategoryParentChild"] = objListOrder; result = sb.ToString(); if (!String.IsNullOrEmpty(sb.ToString())) { dco.Data = result; CacheRepository.Add(dco); } return(result); //new { html = result}; }
public string GetLotTitleUrl(long lot, string title) { return(UrlParser.TitleToUrl(String.Format("Lot{0}~{1}", lot, title.Replace("\"", "'")))); }