Example #1
0
        public static Customer GetByPhoneNumber(string phoneNumber)
        {
            Customer    result = null;
            PhoneNumber phone  = PhoneNumber.Get(phoneNumber);

            if (phone == null)
            {
                return(null);
            }
            SqlConnection cn = GetConnection();

            using (SqlCommand cmd = new SqlCommand("SELECT Customer.*,Person.* FROM Customer INNER JOIN Person ON CustomerPersonId = PersonId WHERE ((PersonPhoneNumberId1=@PhoneNumberId) OR (PersonPhoneNumberId2=@PhoneNumberId) OR (PersonPhoneNumberId3=@PhoneNumberId) OR (PersonPhoneNumberId4=@PhoneNumberId) OR (PersonPhoneNumberId5=@PhoneNumberId) OR (PersonPhoneNumberId6=@PhoneNumberId))", cn))
            {
                BuildSqlParameter(cmd, "@PhoneNumberId", SqlDbType.Int, phone.Id);
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildCustomer(rdr);
                    }
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
Example #2
0
 public static void Refresh(PhoneNumber phoneNumber)
 {
     Refresh(phoneNumber, PhoneNumber.Get(phoneNumber.Id));
 }