Exemplo n.º 1
0
        public IEnumerable <HierarchyLinks> BuildHeirarchyChildLinks(I___BaseTaxonomy taxItem)
        {
            var children = new List <HierarchyLinks>();

            Dictionary <Guid, HierarchyLinks> taxonomyItems = new Dictionary <Guid, HierarchyLinks>();

            foreach (var taxonomy in taxItem.Taxonomies)
            {
                var taxonomyTree = GetTaxonomyHierarchy(taxonomy);

                if (!taxonomyItems.ContainsKey(taxonomyTree.Item1._Id))
                {
                    taxonomyItems.Add(taxonomyTree.Item1._Id, new HierarchyLinks {
                        Text     = taxonomyTree.Item1._Name,
                        Url      = string.Empty,
                        Children = new List <HierarchyLinks>()
                    });
                }

                var folderItem = taxonomyItems[taxonomyTree.Item1._Id];

                foreach (var item in taxonomyTree.Item3)
                {
                    if (!taxonomyItems.ContainsKey(item._Parent._Id))
                    {
                        taxonomyItems.Add(item._Parent._Id, new HierarchyLinks {
                            Text     = item.Item_Name,
                            Url      = SearchTaxonomyUtil.GetSearchUrl(item),
                            Children = new List <HierarchyLinks>()
                        });
                    }

                    var lItem = new HierarchyLinks {
                        Text     = item.Item_Name,
                        Url      = SearchTaxonomyUtil.GetSearchUrl(item),
                        Children = new List <HierarchyLinks>()
                    };

                    if (!taxonomyItems.ContainsKey(item._Id))
                    {
                        taxonomyItems.Add(item._Id, lItem);
                    }
                    var parent = taxonomyItems[item._Parent._Id];
                    var pList  = parent.Children.ToList();
                    if (!pList.Any(a => a.Text.Equals(lItem.Text)))
                    {
                        pList.Add(lItem);
                    }

                    parent.Children = pList;
                }

                if (!children.Any(x => x.Text.Equals(folderItem.Text)))
                {
                    children.Add(folderItem);
                }
            }

            return(children);
        }
Exemplo n.º 2
0
        public HierarchyLinksViewModel(
            I___BaseTaxonomy glassModel,
            ITextTranslator textTranslator,
            ITaxonomyService taxonomyService)
        {
            TextTranslator  = textTranslator;
            TaxonomyService = taxonomyService;

            model = new HierarchyLinks();

            model.Text     = "Related Topics";
            model.Url      = string.Empty;
            model.Children = TaxonomyService.GetHeirarchyChildLinks(glassModel);
        }