//GetCategoriesMapTreeJSON
        public List <CategoryParentChild> GetCategoriesMapTreeJSON(long event_id, bool demo, string strChk = null)
        {
            //StringBuilder sb = new StringBuilder();
            IEventRepository er   = new EventRepository(dataContext, CacheRepository);
            Event            evnt = er.GetEventByID(event_id);

            //string pref = (evnt.IsClickable || demo || evnt.IsAccessable) ? (demo?"d" : "a") : "n";
            //string file = String.Format(@"~\Templates\Different\{0}{1}.htm", pref, event_id);
            //FileInfo fi = new FileInfo(System.Web.HttpContext.Current.Server.MapPath(file));
            //if (fi.Exists)
            //{
            //  TextReader fileReader = new StreamReader(fi.FullName);
            //  sb.Append(fileReader.ReadToEnd());
            //  fileReader.Close();
            //  return (sb.Length > 0) ? new { html = sb.ToString() } : GetCategoriesMapTree(event_id, demo, evnt.IsClickable || demo || evnt.IsAccessable);
            //}
            return(GetCategoriesMapTree(event_id, demo, evnt.IsClickable || demo || evnt.IsAccessable, strChk));
        }
    //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>&nbsp;</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("&nbsp;");
          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();
    }
Esempio n. 3
0
        //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>&nbsp;</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("&nbsp;");
                    }
                    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());
        }