ActivEarth.DAO.GroupDAO.GetAllGroupsByOwner C# (CSharp) Method

GetAllGroupsByOwner() public static method

Retrieves all currently created Groups that have a given Owner.
public static GetAllGroupsByOwner ( User owner ) : List
owner ActivEarth.Objects.Profile.User
return List
        public static List<Group> GetAllGroupsByOwner(User owner)
        {
            List<Group> ownedGroups = new List<Group>();

            using (SqlConnection connection = ConnectionManager.GetConnection())
            {
                var data = new ActivEarthDataProvidersDataContext(connection);

                List<int> groupIds = (from g in data.GroupDataProviders
                                      where g.owner_id == owner.UserID
                                      select g.id
                                      ).ToList();

                foreach (int groupId in groupIds)
                {
                    Group group = GetGroupFromGroupId(groupId);
                    ownedGroups.Add(group);
                }

                return ownedGroups;
            }
        }