Esempio n. 1
0
        public bool UpdateChild(EntryVm newChild)
        {
            var childEntry = ChildEntryVms.FirstOrDefault(e => e.Key == newChild.Key);

            if (childEntry != null)
            {
                newChild.ParentEntry = childEntry.ParentEntry;

                var index = ChildEntryVms.IndexOf(childEntry);
                ChildEntryVms.Remove(childEntry);
                ChildEntryVms.Insert(index, newChild);

                return(true);
            }
            else
            {
                foreach (var child in ChildEntryVms)
                {
                    if (child.UpdateChild(newChild))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 2
0
        internal bool HasChildNode(EntryVm child)
        {
            var foundChild = ChildEntryVms.FirstOrDefault(c => c.Key == child.Key);

            if (foundChild != null)
            {
                return(true);
            }
            else
            {
                foreach (var myChild in ChildEntryVms)
                {
                    if (myChild.HasChildNode(child))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 3
0
        public bool DeleteChild(EntryVm obsoleteChild)
        {
            var childEntry = ChildEntryVms.FirstOrDefault(e => e.Key == obsoleteChild.Key);

            if (childEntry != null)
            {
                ChildEntryVms.Remove(childEntry);
                return(true);
            }
            else
            {
                foreach (var child in ChildEntryVms)
                {
                    if (child.DeleteChild(obsoleteChild))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }