public Member[] GetFriends( String webMemberID, String password ) { if (webMemberID == null) throw new ArgumentNullException("webMemberID"); if (password == null) throw new ArgumentNullException("password"); IList<Member> friends = new List<Member>(); using (var connection = N2FDatabase.OpenConnection()) { SqlCommand cmd = connection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "HG_GetGeoMessageFriends"; cmd.Parameters.AddWithValue("@webMemberID", webMemberID); cmd.Parameters.AddWithValue("@password", password); SqlParameter returnValueParam = cmd.Parameters.Add("return_value", SqlDbType.Int); returnValueParam.Direction = ParameterDirection.ReturnValue; SqlDataReader reader = cmd.ExecuteReader(); if (returnValueParam.Value<Int32>() == -1) throw new ArgumentException(Resources.Argument_BadCredentials); try { while (reader.Read()) friends.Add( new Member( (String)reader[0] /* WebMemberID */, (String)reader[1] /* NickName */)); } finally { if (reader != null) reader.Close(); } } Member[] result = new Member[friends.Count]; friends.CopyTo(result, 0); return result; }
private static Member[] GetMessageReceivers(Int32 messageID, SqlConnection connection, SqlTransaction transaction) { SqlCommand cmd = new SqlCommand("HG_GetGeoMessageReceivers", connection, transaction); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@messageID", messageID); IList<Member> receivers = new List<Member>(); SqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) receivers.Add( new Member( (String)reader[0] /* WebMemberID */, (String)reader[1] /* NickName */)); } finally { if (reader != null) reader.Close(); } Member[] result = new Member[receivers.Count]; receivers.CopyTo(result, 0); return result; }