public AdminTree GetTree(int?id)
        {
            AdminTree adminTree = new AdminTree {
                RootContoller = "Webpage"
            };
            IQueryOver <Webpage, Webpage> query = _session.QueryOver <Webpage>().Where(x => x.Parent.Id == id);
            int maxChildNodes = 1000;

            if (id.HasValue)
            {
                Webpage parent = _session.Get <Webpage>(id);
                if (parent != null)
                {
                    DocumentMetadata metaData = parent.GetMetadata();
                    maxChildNodes = metaData.MaxChildNodes;
                    query         = ApplySort(metaData, query);
                }
            }
            else
            {
                adminTree.IsRootRequest = true;
                query = query.OrderBy(x => x.DisplayOrder).Asc;
            }

            int rowCount = query.Cacheable().RowCount();

            query.Take(maxChildNodes).Cacheable().List().ForEach(doc =>
            {
                DocumentMetadata documentMetadata = doc.GetMetadata();
                AdminTreeNode node = new AdminTreeNode
                {
                    Id                 = doc.Id,
                    ParentId           = doc.ParentId,
                    Name               = doc.Name,
                    IconClass          = documentMetadata.IconClass,
                    NodeType           = "Webpage",
                    Type               = documentMetadata.Type.FullName,
                    HasChildren        = _treeNavService.GetWebpageNodes(doc.Id).Nodes.Any(),
                    Sortable           = documentMetadata.Sortable,
                    CanAddChild        = _validWebpageChildrenService.AnyValidWebpageDocumentTypes(doc),
                    IsPublished        = doc.Published,
                    RevealInNavigation = doc.RevealInNavigation,
                    Url                = _urlHelper.Action("Edit", "Webpage", new { id = doc.Id })
                };
                adminTree.Nodes.Add(node);
            });
            if (rowCount > maxChildNodes)
            {
                adminTree.Nodes.Add(new AdminTreeNode
                {
                    IconClass  = "glyphicon glyphicon-plus",
                    IsMoreLink = true,
                    ParentId   = id,
                    Name       = (rowCount - maxChildNodes) + " More",
                    Url        = _urlHelper.Action("Search", "WebpageSearch", new { parentId = id }),
                });
            }
            return(adminTree);
        }
Пример #2
0
        public void NavigationController_WebsiteTree_ShouldReturnWebsiteTreeAsModel()
        {
            A.CallTo(() => _treeNavService.GetWebpageNodes(null)).Returns(new AdminTree());

            PartialViewResult partialViewResult = _navigationController.WebSiteTree(null);

            partialViewResult.Model.Should().BeOfType <AdminTree>();
        }
Пример #3
0
        public PartialViewResult WebSiteTree(int?id)
        {
            AdminTree admintree = _treeNavService.GetWebpageNodes(id);

            return(PartialView("TreeList", admintree));
        }