예제 #1
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);

            cmd.Parameters.Add(new SqlParameter("@BandId", newBand.GetId().ToString()));
            cmd.Parameters.Add(new SqlParameter("@VenueId", this.GetId().ToString()));
            cmd.ExecuteNonQuery();

            DB.CloseSqlConnection(conn);
        }
예제 #2
0
        public void DeleteBand(Band newBand)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();
            SqlCommand cmd = new SqlCommand("DELETE FROM bands_venues WHERE band_id = @BandId AND venue_id = @VenueId;", conn);

            cmd.Parameters.Add(new SqlParameter("@BandId", newBand.GetId().ToString()));
            cmd.Parameters.Add(new SqlParameter("@VenueId", this.GetId().ToString()));
            cmd.ExecuteNonQuery();

            DB.CloseSqlConnection(conn);
        }
예제 #3
0
        public void Find_OneBandId_ReturnBandFromDatabase()
        {
            //Arrange
            Band testBand = new Band("Green Day");

            testBand.Save();

            //Act
            Band foundBand = Band.Find(testBand.GetId());

            //Assert
            Assert.Equal(testBand, foundBand);
        }
예제 #4
0
 public override bool Equals(System.Object randomBand)
 {
     if (!(randomBand is Band))
     {
         return(false);
     }
     else
     {
         Band newBand      = (Band)randomBand;
         bool idEquality   = (this.GetId() == newBand.GetId());
         bool nameEquality = (this.GetName() == newBand.GetName());
         return(idEquality && nameEquality);
     }
 }
예제 #5
0
 public override bool Equals(System.Object otherBand)
 {
     // This function overrides the built-in Equals Method to ensure it returns true if two band objects are identical
     if (!(otherBand is Band))
     {
         return(false);
     }
     else
     {
         Band newBand      = (Band)otherBand;
         bool nameEquality = this.GetName() == newBand.GetName();
         bool idEquality   = this.GetId() == newBand.GetId();
         return(nameEquality && idEquality);
     }
 }
예제 #6
0
        public void Save_OneBand_BandSavedWithCorrectID()
        {
            //Arrange
            Band testBand = new Band("Green Day");

            testBand.Save();
            Band savedBand = Band.GetAll()[0];

            //Act
            int output = savedBand.GetId();
            int verify = testBand.GetId();

            //Assert
            Assert.Equal(verify, output);
        }
예제 #7
0
        public override bool Equals(System.Object otherBand)
        {
            if (!(otherBand is Band))
            {
                return(false);
            }
            else
            {
                Band newBand              = (Band)otherBand;
                bool idEquality           = this.GetId() == newBand.GetId();
                bool nameEquality         = this.GetName() == newBand.GetName();
                bool agentContactEquality = this.GetAgentContact() == newBand.GetAgentContact();
                bool agentEquality        = this.GetAgent() == newBand.GetAgent();
                bool genreEquality        = this.GetGenre() == newBand.GetGenre();
                bool leaderEquality       = this.GetLeader() == newBand.GetLeader();
                bool membersEquality      = this.GetMembers() == newBand.GetMembers();
                bool originPlaceEquality  = this.GetOriginplace() == newBand.GetOriginplace();
                bool originYearEquality   = this.GetoriginYear() == newBand.GetoriginYear();

                return(idEquality && nameEquality && agentEquality && agentContactEquality && genreEquality && leaderEquality && membersEquality && originPlaceEquality && originYearEquality);
            }
        }