Ejemplo n.º 1
0
 public CompanyStorage()
 {
     lastId = 0;
     root   = new EmployeeNode()
     {
         Node     = null,
         Children = new List <EmployeeNode>()
     };
 }
Ejemplo n.º 2
0
 void DeleteChildren(EmployeeNode parent, EmployeeNode child)
 {
     if (child.Children.Any())
     {
         foreach (var node in child.Children)
         {
             DeleteChildren(child, node);
         }
     }
     else
     {
         parent.Children.Remove(child);
     }
 }
Ejemplo n.º 3
0
        EmployeeNode FindById(EmployeeNode parent, int Id)
        {
            var rez = parent.Children.FirstOrDefault(x => x.Node.Id == Id);

            if (rez != null)
            {
                return(rez);
            }
            foreach (var node in parent.Children)
            {
                rez = FindById(node, Id);
                if (rez != null)
                {
                    break;
                }
            }
            return(rez);
        }
Ejemplo n.º 4
0
        EmployeeNode GetEmpolyeeParentById(EmployeeNode parent, EmployeeNode child)
        {
            var rez = parent.Children.FirstOrDefault(x => x.Node.Id == child.Node.Id);

            if (rez != null)
            {
                return(parent);
            }
            foreach (var node in parent.Children)
            {
                rez = GetEmpolyeeParentById(node, child);
                if (rez != null)
                {
                    break;
                }
            }
            return(rez);
        }