public TOCNode GetTOCByTOCId(int tocId, TOCNode rootTOCNode)
 {
     if (rootTOCNode != null)
     {
         var isRootNode = (tocId == 0);
         if (isRootNode)
         {
             return(rootTOCNode);
         }
         if (rootTOCNode.HasChildNodes())
         {
             foreach (var item in rootTOCNode.ChildNodes)
             {
                 if (item.ID == tocId)
                 {
                     return(item);
                 }
                 else
                 {
                     rootTOCNode = GetTOCByTOCId(tocId, item);
                     if (rootTOCNode != null)
                     {
                         return(rootTOCNode);
                     }
                 }
             }
         }
     }
     return(null);
 }
 public void BuildTocNode(TOCNode newNode, TOCNode parentTOC, List <TOCNode> nodeSource)
 {
     newNode.ParentNode = parentTOC;
     newNode.ChildNodes = nodeSource.FindAll(o => o.ParentId == newNode.ID);
     if (newNode.HasChildNodes())
     {
         nodeSource.RemoveAll(o => o.ParentId == newNode.ID);
         foreach (var item in newNode.ChildNodes)
         {
             BuildTocNode(item, newNode, nodeSource);
         }
     }
 }