/// <summary> /// Activates a new phone number for the given customer name. /// </summary> public void ActivatePhoneNumber(PhoneNumber phone, string name) { db.Connect(); db.ActivatePhoneNumber(phone, db.GetCustomer(name)); db.Close(); }
public void TestGetAllPhoneNumbersFromCustomer() { IRepository customerRepo = new CustomerRepository(); PhoneNumber control = new PhoneNumber() { CountryCode = 971, AreaCode = 56, Number = 1111111 }; PhoneNumber actual = customerRepo.GetPhoneNumberByID(1)[0]; Assert.AreEqual(control.CountryCode, actual.CountryCode); Assert.AreEqual(control.AreaCode, actual.AreaCode); Assert.AreEqual(control.Number, actual.Number); }
public void TestActivatePhoneNumber() { IRepository customerRepo = new CustomerRepository(); customerRepo.ActivatePhoneNumber(new PhoneNumber() { AreaCode = 11, CountryCode = 111, Number = 1234567 }, 2); PhoneNumber control = new PhoneNumber() { CountryCode = 111, AreaCode = 11, Number = 1234567 }; List<PhoneNumber> numbers = customerRepo.GetPhoneNumberByID(2); //Get the last entry PhoneNumber actual = numbers[numbers.Count - 1]; Assert.AreEqual(control.CountryCode, actual.CountryCode); Assert.AreEqual(control.AreaCode, actual.AreaCode); Assert.AreEqual(control.Number, actual.Number); }
/// <summary> /// Activates a new phone number for the given customer id. /// </summary> public void ActivatePhoneNumber(PhoneNumber phone, int id) { db.Connect(); db.ActivatePhoneNumber(phone, db.GetCustomer(id)); db.Close(); }
/// <summary> /// Adds a new phone number to the given customer /// </summary> internal void ActivatePhoneNumber(PhoneNumber phone, Customer customer) { //Mock DB Code Customers.First(c => c.ID == customer.ID).Phonenumbers.Add(phone); //How a real implementation could look //using (SqlConnection connection = new SqlConnection(_connectionString)) //{ // SqlCommand command = new SqlCommand("SaveCustomer", connection); // command.CommandType = CommandType.StoredProcedure; // command.Parameters.Add(new SqlParameter("@name", customer.Name)); // command.Parameters.Add(new SqlParameter("@id", customer.ID)); // command.Parameters.Add(new SqlParameter("@phonenumbers", customer.Phonenumbers)); // command.Connection.Open(); // command.ExecuteNonQuery(); //} }