ActivEarth.DAO.PrivacySettingDAO.GetPrivacySettingFromPrivacySettingId C# (CSharp) Method

GetPrivacySettingFromPrivacySettingId() public static method

Retrieves a PrivacySetting from the DB based on its ID.
public static GetPrivacySettingFromPrivacySettingId ( int privacySettingId ) : PrivacySetting
privacySettingId int Identifier of the privacy setting to retrieve.
return ActivEarth.Objects.Profile.PrivacySetting
        public static PrivacySetting GetPrivacySettingFromPrivacySettingId(int privacySettingId)
        {
            PrivacySetting toReturn;
            using (SqlConnection connection = ConnectionManager.GetConnection())
            {
                var data = new ActivEarthDataProvidersDataContext(connection);
                toReturn = (from p in data.PrivacySettingDataProviders
                        where p.id == privacySettingId
                        select
                            new PrivacySetting
                            {
                                ID = p.id,
                                Email = p.email,
                                Gender = p.gender,
                                Age = p.age,
                                Height = p.height,
                                Weight = p.weight,
                                Group = p.groups,
                                ProfileVisibility = p.profile_visibility,
                                UserID = p.user_id
                            }).FirstOrDefault();
            }

            if (toReturn != null)
            {
                toReturn.User = UserDAO.GetUserFromUserId(toReturn.UserID);
            }
            return toReturn;
        }