public void AddVenues(Venue newVenue) { SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO venues_bands (venue_id, band_id) VALUES (@VenueId,@BandId)", conn); SqlParameter venueIdParameter = new SqlParameter(); venueIdParameter.ParameterName = "@VenueId"; venueIdParameter.Value = newVenue.GetId(); SqlParameter bandIdParameter = new SqlParameter(); bandIdParameter.ParameterName = "@BandId"; bandIdParameter.Value = this.GetId(); cmd.Parameters.Add(venueIdParameter); cmd.Parameters.Add(bandIdParameter); cmd.ExecuteNonQuery(); if (conn != null) { conn.Close(); } }
public void T5_Find_FindNameInDatabase() { //arrange Venue testVenue = new Venue("Pheonix"); testVenue.Save(); //act Venue foundVenue = Venue.Find(testVenue.GetId()); //Assert Assert.Equal(testVenue, foundVenue); }
public void T4_Save_AsignsIdToObject() { //arrange Venue newVenue = new Venue("Pheonix"); //action newVenue.Save(); Venue savedVenue = Venue.GetAll()[0]; int result = savedVenue.GetId(); int testId = newVenue.GetId(); //assert Assert.Equal(testId, result); }
public override bool Equals(System.Object otherVenue) { if (!(otherVenue is Venue)) { return(false); } else { Venue newVenue = (Venue)otherVenue; bool idEquality = (this.GetId() == newVenue.GetId()); bool nameEquality = (this.GetName() == newVenue.GetName()); return(idEquality && nameEquality); } }
public void AddVenues(Venue newVenue) { SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO venues_bands (venue_id, band_id) VALUES (@VenueId,@BandId)",conn); SqlParameter venueIdParameter = new SqlParameter(); venueIdParameter.ParameterName= "@VenueId"; venueIdParameter.Value= newVenue.GetId(); SqlParameter bandIdParameter = new SqlParameter(); bandIdParameter.ParameterName= "@BandId"; bandIdParameter.Value= this.GetId(); cmd.Parameters.Add(venueIdParameter); cmd.Parameters.Add(bandIdParameter); cmd.ExecuteNonQuery(); if(conn != null) { conn.Close(); } }