Exemplo n.º 1
0
        public IList <Goal> GetChildren()
        {
            GoalContext db = new GoalContext();

            IList <Goal> children = db.Goals.Where(item => item.parent == id).ToList();

            return(children);
        }
Exemplo n.º 2
0
        public void DeleteChildren()
        {
            IList <Goal> children = GetChildren();

            if (children.Any())
            {
                GoalContext db = new GoalContext();

                foreach (var child in children)
                {
                    // Run DeleteChildren recursively on children until no more children have children.
                    child.DeleteChildren();

                    // Then remove the child.
                    Goal childToRemove = db.Goals.Find(child.id);
                    db.Goals.Remove(childToRemove);
                    db.SaveChanges();
                }
            }
        }