public void TestUpdate()
        {
            IPerformanceDao dao         = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase());
            Performance     performance = dao.findById(1);
            IArtistDao      artistDao   = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            Artist          artist      = artistDao.findById(2);

            performance.Artist      = artist;
            performance.StagingTime = DateTime.UtcNow;
            dao.Update(performance);

            Performance result = dao.findById(1);

            //Assert.AreEqual(result.StagingTime, performance.StagingTime);
            Assert.AreEqual(result.Artist.Id, performance.Artist.Id);
        }
Esempio n. 2
0
        public bool CanclePerformance(int performanceId)
        {
            IPerformanceDao dao = DALFactory.CreatePerformanceDao(database);
            Performance     p   = dao.findById(performanceId);

            p.Canceld = true;
            return(dao.Update(p));
        }
        public void TestFindById()
        {
            IPerformanceDao dao         = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase());
            Performance     performance = dao.findById(1);

            Assert.AreEqual(performance.Id, 1);
            Assert.IsFalse(performance.Canceld);
        }
Esempio n. 4
0
        public bool PostponePerformance(int performanceId, DateTime date, int venueId)
        {
            IPerformanceDao dao      = DALFactory.CreatePerformanceDao(database);
            IVenueDao       venueDao = DALFactory.CreateVenueDao(database);
            Performance     p        = dao.findById(performanceId);

            if (this.CheckPostponeIsPossible(performanceId, date, venueId))
            {
                p.StagingTime = date;
                Venue v = venueDao.findById(venueId);
                p.Venue = v;
                return(dao.Update(p));
            }
            return(false);
        }
Esempio n. 5
0
        public bool CheckPostponeIsPossible(int performanceId, DateTime date, int venueId)
        {
            IPerformanceDao     dao               = DALFactory.CreatePerformanceDao(database);
            IVenueDao           venueDao          = DALFactory.CreateVenueDao(database);
            Performance         toPostpone        = dao.findById(performanceId);
            IList <Performance> otherPerformances = dao.FindPerormanceByDay(date);

            bool foundConflict = false;

            foreach (Performance p in otherPerformances)
            {
                if (p.Id == toPostpone.Id)
                {
                    continue;
                }


                DateTime postPoneDate = new DateTime(date.Year, date.Month, date.Day, date.Hour, 0, 0);
                DateTime currentDate  = new DateTime(p.StagingTime.Year, p.StagingTime.Month, p.StagingTime.Day, p.StagingTime.Hour, 0, 0);


                if (toPostpone.Artist.Id == p.Artist.Id)
                {
                    if (postPoneDate >= currentDate.AddHours(-2) && postPoneDate <= currentDate.AddHours(2))
                    {
                        foundConflict = true;
                        break;
                    }
                }
                if (p.Venue.Id == venueId && postPoneDate == currentDate)
                {
                    foundConflict = true;
                    break;
                }
            }
            return(!foundConflict);
        }