Exemple #1
0
        public void TestInsert()
        {
            // arrange
            bool expectedValue = true;
               Performance newPerformance = new Performance(new DateTime(2015, 7, 23), 19, "MadMatt", "T2");
            bool beforeInsert = pDao.GetAll().Count == 5;

            // act
            pDao.Insert(newPerformance);
            bool afterInsert = pDao.GetAll().Count == 6;

            // assert
            bool actualValue = (beforeInsert && afterInsert);
            Assert.AreEqual(expectedValue, actualValue, "Performance has not been inserted successfully.");
        }
Exemple #2
0
 public PerformanceVM(Performance performance)
 {
     this.performance = performance;
 }
Exemple #3
0
 public bool Update(Performance p)
 {
     return database.ExecuteNonQuery(CreateUpdateCommand(p.Date, p.Time, p.Artist, p.Venue)) == 1;
 }
Exemple #4
0
 public bool DeletePerformance(Performance performance)
 {
     return performanceDao.Delete(performance.Date, performance.Time, performance.Venue);
 }
Exemple #5
0
 public bool UpdatePerformance(Performance performance)
 {
     if (PerformanceIsPossible(performance))
         return performanceDao.Update(performance);
     return false;
 }
Exemple #6
0
        public bool PerformanceIsPossible(Performance performance)
        {
            foreach (Performance p in GetPerformancesByDate(performance.Date))
            {
                // at least 1 hour break
                if (p.Time == performance.Time - 1 || p.Time == performance.Time + 1)
                    if (p.Artist == performance.Artist)
                        return false;

                // can't have 2 performances simultaneously
                if (p.Time == performance.Time && p.Artist == performance.Artist)
                    return false;
            }
            return true;
        }
Exemple #7
0
 public bool InsertPerformance(Performance performance)
 {
     if (PerformanceIsPossible(performance))
         return performanceDao.Insert(performance);
     return false;
 }