Example #1
0
        public void Test_SaveAssignsIdToObject()
        {
            // Arrange
            firstBand.Save();

            // Act
            Band testBand = Band.GetAllBands()[0];
            int  result   = firstBand.GetBandId();
            int  testId   = testBand.GetBandId();

            // Assert
            Assert.Equal(testId, result);
        }
Example #2
0
        public void AddBand(Band newBand)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd              = new SqlCommand("INSERT INTO bands_venues (band_id, venue_id) VALUES (@BandId, @VenueId);", conn);
            SqlParameter bandIdParameter  = new SqlParameter("@BandId", newBand.GetBandId());
            SqlParameter venueIdParameter = new SqlParameter("@VenueId", this.GetVenueId());

            cmd.Parameters.Add(bandIdParameter);
            cmd.Parameters.Add(venueIdParameter);

            cmd.ExecuteNonQuery();
            if (conn != null)
            {
                conn.Close();
            }
        }