private void Update(Group group)
 {
     group.LastUpdated = group.UtcNow;
     this.groupRepository.Update(group);
 }
        public virtual IEnumerable<Group> GetDescendants(Group grp)
        {
            if (grp == null) throw new ArgumentNullException("group");

            var children = GetChildren(grp);
            var result = children;
            foreach (var child in children)
            {
                result = result.Union(GetDescendants(child));
            }
            return result;
        }
 public virtual IEnumerable<Group> GetChildren(Group grp)
 {
     if (grp == null) throw new ArgumentNullException("group");
     var ids = grp.Children.Select(x=>x.ChildGroupID).ToArray();
     if (ids.Length == 0) return Enumerable.Empty<Group>();
     return this.groupRepository.GetAll().Where(x => ids.Contains(x.ID));
 }
        void RemoveChildGroup(Group group, Guid childGroupID)
        {
            if (group == null) throw new ArgumentNullException("group");

            if (group.ID == childGroupID) return;

            var child = group.Children.SingleOrDefault(x => x.ChildGroupID == childGroupID);
            if (child != null)
            {
                group.Children.Remove(child);
            }
        }