/// <summary> /// Saves the customer to the database /// </summary> public void SaveToDB() { CustomerClient temp = new CustomerClient(); if (temp.CheckIfEmailIsTaken(Email)) { // Get and open the connection using (MySqlConnection con = ApplicationSettings.GetConnection()) { con.Open(); // Insert the customer's properties to the database MySqlCommand cmd = new MySqlCommand( "INSERT INTO `customer`(`first_name`, `last_name`, `email`, `phone`) " + "VALUES (@fname,@lname,@email,@phone)", con); cmd.Parameters.AddWithValue("@fname", this.FirstName); cmd.Parameters.AddWithValue("@lname", this.LastName); cmd.Parameters.AddWithValue("@email", this.Email); cmd.Parameters.AddWithValue("@phone", this.Phone); cmd.ExecuteNonQuery(); // Retrieve the id from the database and assign it to the object this.ID = Convert.ToInt32(cmd.LastInsertedId); // Close the connection con.Close(); } } }
public void VerifyEmail_Test_fail() { CustomerClient client = new CustomerClient(); Assert.AreEqual(client.CheckIfEmailIsTaken("*****@*****.**"), false); // Verify it is indeed in database - for now we do it manually }
public void VerifyEmail_Test() { CustomerClient client = new CustomerClient(); Assert.AreEqual(client.CheckIfEmailIsTaken("*****@*****.**"), true); // Verify it is indeed in database - for now we do it manually }