private void FillPageTreeNode(TreeViewPageNode parentTreeNode,
                                      IList <TreeViewNode> treeViewNodes)
        {
            int?parentId = null;

            if (parentTreeNode.Id > 0)
            {
                parentId = parentTreeNode.Id;
            }

            parentTreeNode.ChildNodes = treeViewNodes
                                        .Where(node => parentId == node.ParentId).Select(node =>
            {
                var pageTreeNode = new TreeViewPageNode()
                {
                    Id         = node.Id,
                    ParentId   = node.ParentId,
                    NodeName   = node.NodeName,
                    IsExpanded = false,
                };

                return(pageTreeNode);
            }).ToList();

            foreach (var treeNode in parentTreeNode.ChildNodes)
            {
                FillPageTreeNode(treeNode, treeViewNodes);
            }
        }
        private void FillPageTreeNode(TreeViewPageNode parentTreeNode, 
            IList<TreeViewNode> treeViewNodes)
        {
            int? parentId = null;

            if (parentTreeNode.Id > 0)
                parentId = parentTreeNode.Id;

            parentTreeNode.ChildNodes = treeViewNodes
                .Where(node => parentId == node.ParentId).Select(node =>
            {
                var pageTreeNode = new TreeViewPageNode()
                {
                    Id = node.Id,
                    ParentId = node.ParentId,
                    NodeName = node.NodeName,
                    IsExpanded = false,
                };

                return pageTreeNode;

            }).ToList();

            foreach (var treeNode in parentTreeNode.ChildNodes)
            {
                FillPageTreeNode(treeNode, treeViewNodes);
            }
        }
        public TreePageItem GetTreePageItem()
        {
            var treePageItem = new TreePageItem();

            var rootTreeNode = new TreeViewPageNode();
            FillPageTreeNode(rootTreeNode, treeViewDataRepository.GetAllTreeViewNodes());
            treePageItem.TreeViewPageNodes = rootTreeNode.ChildNodes;

            return treePageItem;
        }
        public TreePageItem GetTreePageItem()
        {
            var treePageItem = new TreePageItem();

            var rootTreeNode = new TreeViewPageNode();

            FillPageTreeNode(rootTreeNode, treeViewDataRepository.GetAllTreeViewNodes());
            treePageItem.TreeViewPageNodes = rootTreeNode.ChildNodes;

            return(treePageItem);
        }