Exemple #1
0
        public object GetRootNodes()
        {
            RedirectDomain[] domains = Repository.GetDomains();

            List <RedirectRootNode> temp = new List <RedirectRootNode>();

            foreach (RedirectDomain domain in domains.Where(x => x.RootNodeId > 0).DistinctBy(x => x.RootNodeId))
            {
                // Get the root node from the content service
                IContent content = ApplicationContext.Services.ContentService.GetById(domain.RootNodeId);

                // Skip if not found via the content service
                if (content == null)
                {
                    continue;
                }

                // Skip if the root node is located in the recycle bin
                if (content.Path.StartsWith("-1,-20,"))
                {
                    continue;
                }

                // Append the root node to the result
                temp.Add(RedirectRootNode.GetFromContent(content));
            }

            return(new {
                total = temp.Count,
                data = temp.OrderBy(x => x.Id)
            });
        }
Exemple #2
0
        /// <summary>
        /// Returns an array of all rode nodes configured in Umbraco.
        /// </summary>
        /// <returns>An array of <see cref="RedirectRootNode"/> representing the root nodes.</returns>
        public RedirectRootNode[] GetRootNodes()
        {
            // Multiple domains may be configured for a single node, so we need to group the domains before proceeding
            var domainsByRootNodeId = GetDomains().GroupBy(x => x.RootNodeId);

            return((
                       from domainGroup in domainsByRootNodeId
                       let content = _contentService.GetById(domainGroup.First().RootNodeId)
                                     where content != null && !content.Trashed
                                     orderby content.Id
                                     select RedirectRootNode.GetFromContent(content, domainGroup)
                       ).ToArray());
        }
        public object GetRootNodes()
        {
            RedirectDomain[] domains = Repository.GetDomains();

            List <RedirectRootNode> temp = new List <RedirectRootNode>();

            foreach (RedirectDomain domain in domains.Where(x => x.RootNodeId > 0).DistinctBy(x => x.RootNodeId))
            {
                IContent content = ApplicationContext.Services.ContentService.GetById(domain.RootNodeId);
                if (content == null)
                {
                    return(null);
                }
                temp.Add(RedirectRootNode.GetFromContent(content));
            }

            return(new {
                total = temp.Count,
                data = temp.OrderBy(x => x.Id)
            });
        }