public static List <BootstrapTreeNode> GetChilds(int nodeid)
        {
            clsDbGeneral             db       = new clsDbGeneral();
            DataTable                dt       = db.GetData("SELECT   Department_Code, Department_Name, Parent_Department_Code FROM   HRMIS_tblDepartment where Parent_Department_Code=" + nodeid);
            List <BootstrapTreeNode> toreturn = new List <BootstrapTreeNode>();

            foreach (DataRow row in dt.Rows)
            {
                BootstrapTreeNode nd = new BootstrapTreeNode();
                nd.text = row["Department_Name"].ToString();
                if (HaveChildNodes((int)row["Department_Code"]))
                {
                    nd.nodes      = GetChilds((int)row["Department_Code"]);
                    nd.selectable = true;
                    nd.id         = (int)row["Department_Code"];
                }
                else
                {
                    nd.selectable = true;
                    nd.id         = (int)row["Department_Code"];
                }

                toreturn.Add(nd);
            }
            return(toreturn);
        }
        private List <BootstrapTreeNode> CreateBootstrapTreeNodes(List <RouteMetaData> routeMetaDatas,
                                                                  int segmentIndex = 1)
        {
            //routeMetaDatas.GroupBy(x => new DirectoryInfo(x.PageRoute).Root.Name);
            var result = routeMetaDatas.GroupBy(x =>
            {
                if (string.IsNullOrEmpty(x.PageRoute))
                {
                    return(string.Empty);
                }

                return(new Uri("file://" + x.PageRoute).Segments[segmentIndex].Replace("/", ""));
            }).Select(x =>
            {
                var node = new BootstrapTreeNode()
                {
                    Text            = HttpUtility.UrlDecode(x.Key),
                    Id              = x.First().Id,
                    Url             = x.First().PageRoute,
                    PageSource      = x.First().RelativePath,
                    PageModelSource = x.First().RelativePath + ".cs"
                };

                var children =
                    x.Where(w => !string.IsNullOrEmpty(w.PageRoute))
                    .Where(w => new Uri("file://" + w.PageRoute).Segments.Length - 1 > segmentIndex).ToList();

                if (node.PageSource.Contains("HTTP"))
                {
                    //Carter Route
                    node.PageSource      = "/Pages" + x.First().PageRoute + ".cs";
                    node.PageModelSource = null;

                    if (!children.Any())
                    {
                        node.Methods =
                            x.Select(w => w.RelativePath.Split(" ").Last())
                            .Where(t => t != "HEAD")
                            .ToArray();
                    }
                }

                if (children.Any())
                {
                    node.Nodes = CreateBootstrapTreeNodes(
                        children,
                        segmentIndex + 1);
                }

                return(node);
            })
                         .OrderBy(x => x.Text)
                         .Where(x => !string.IsNullOrWhiteSpace(x.Text))
                         .ToList();

            return(result);
        }