private List <AreaNodeModel> LoadChildNodes(AreaNodeModel parentNode, List <AreaNodeModel> allNodes) { var childNodes = allNodes.Where(r => r.ParentId == parentNode.Id).ToList(); if (childNodes.Any()) { foreach (var n in childNodes) { n.Nodes = LoadChildNodes(n, allNodes); } parentNode.Nodes = childNodes; return(childNodes); } return(null); }
private List <AreaNodeModel> LoadChildNodesList(AreaNodeModel parentNode, List <AreaNodeModel> allNodes) { var childNodes = allNodes.Where(r => r.ParentId == parentNode.Id).ToList(); var list = new List <AreaNodeModel>(); if (childNodes.Any()) { foreach (var n in childNodes) { list.Add(n); var tep = LoadChildNodesList(n, allNodes); if (tep != null && tep.Count > 0) { list.AddRange(tep); } } return(list); } return(null); }