// 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};
        }
        //GetCategoriesMapTree
        private void GetCategoriesMapTreeChild(StringBuilder sb, JsTreeNode js, Event evnt, bool demo, CategoryChildLink objCategoryChildLink = null, CategoryChild objCategoryChild = null)
        {
            if (evnt.IsClickable || demo || evnt.IsAccessable)
            {
                objCategoryChildLink.ChildLinkUrl  = js.data.attributes.href;
                objCategoryChildLink.ChildLinkName = js.data.title.ToUpper();
                objCategoryChild.ChildLinkUrl      = js.data.attributes.href;
                objCategoryChild.ChildLinkName     = js.data.title.ToUpper();

                //sb.AppendFormat("<li ischild='{2}' ><a style='{4}' href='{0}'>{1}</a> {3}", js.data.attributes.href, (js.data.attributes.rel != "main") ? js.data.title : js.data.title.ToUpper(), js.data.attributes.rel != "main", (!String.IsNullOrEmpty(js.data.icon)) ? "(" + js.data.icon + ")" : String.Empty, (js.data.attributes.rel != "main") ? " font-weight:normal;color:#0072B0;" : "font-weight:bold;color:gray");
                sb.AppendFormat("<li ischild='{2}' ><a style='{4}' href='{0}'>{1}</a> {3}", js.data.attributes.href, (js.data.attributes.rel != "main") ? js.data.title : js.data.title.ToUpper(), js.data.attributes.rel != "main", (!String.IsNullOrEmpty(js.data.icon)) ? "(" + js.data.icon + ")" : String.Empty, (js.data.attributes.rel != "main") ? " color:gray" : "font-weight:bold;color:gray");
            }
            else
            {
                objCategoryChildLink.ChildLinkUrl  = js.data.attributes.rel;
                objCategoryChildLink.ChildLinkName = js.data.title.ToUpper();
                objCategoryChild.ChildLinkUrl      = js.data.attributes.rel;
                objCategoryChild.ChildLinkName     = js.data.title.ToUpper();
                // sb.AppendFormat("<li ischild='{1}' ><span style='{3}'>{0}</span> {2}", (js.data.attributes.rel != "main") ? js.data.title : js.data.title.ToUpper(), js.data.attributes.rel != "main", (!String.IsNullOrEmpty(js.data.icon)) ? "(" + js.data.icon + ")" : String.Empty, (js.data.attributes.rel != "main") ? " font-weight:normal;color:#0072B0;" : "font-weight:bold;color:gray");
                sb.AppendFormat("<li ischild='{1}' ><span style='{3}'>{0}</span> {2}", (js.data.attributes.rel != "main") ? js.data.title : js.data.title.ToUpper(), js.data.attributes.rel != "main", (!String.IsNullOrEmpty(js.data.icon)) ? "(" + js.data.icon + ")" : String.Empty, (js.data.attributes.rel != "main") ? " color:gray" : "font-weight:bold;color:gray");
            }

            if (js.children != null && js.children.Count() > 0)
            {
                sb.Append("<ul>");
                foreach (JsTreeNode j in js.children)
                {
                    GetCategoriesMapTreeChild(sb, j, evnt, demo);
                }
                sb.Append("</ul>");
            }
            sb.AppendFormat("</li>");
        }