public bool SavePerformance(Performance p)
        {
            IPerformanceDao dao = DALFactory.CreatePerformanceDao(database);

            dao.Insert(p);
            return(true);
        }
Example #2
0
        void InsertDummyData(IPerformanceDao dao)
        {
            CreateTestData();

            foreach (var item in items)
            {
                dao.Insert(item);
            }
        }
        public void TestInsert()
        {
            Performance performance = new Performance();
            IArtistDao  artistDao   = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            Artist      artist      = artistDao.findById(1);

            IVenueDao venueDao = DALFactory.CreateVenueDao(DALFactory.CreateDatabase());
            Venue     venue    = venueDao.findById(1);

            performance.Artist      = artist;
            performance.Venue       = venue;
            performance.StagingTime = DateTime.Now;

            IPerformanceDao dao = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase());

            dao.Insert(performance);

            IList <Performance> result = dao.findAll();

            Assert.AreEqual(result.Count, 3);
        }
        private static void CreatePerformances()
        {
            Console.WriteLine("Insert Performances ");
            IVenueDao       venueDao       = DALFactory.CreateVenueDao(DALFactory.CreateDatabase());
            IPerformanceDao performanceDao = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase());
            IArtistDao      artistDao      = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            int             year           = 2016;
            int             month          = 01;
            int             day            = 23;

            for (int i = 0; i < 3; i++)
            {
                int count  = 1;
                int hour   = 14;
                int min    = 00;
                int second = 00;
                for (int j = 1; j <= 40; j++)
                {
                    count++;
                    if (count == 10)
                    {
                        hour  = hour + 2;
                        count = 1;
                    }
                    DateTime dt = new DateTime(year, month, day, hour, min, second);

                    Venue       venue  = venueDao.findById(j);
                    Artist      artist = artistDao.findById(j);
                    Performance p      = new Performance();
                    p.Artist      = artist;
                    p.Venue       = venue;
                    p.StagingTime = dt;
                    performanceDao.Insert(p);
                }
                day++;
            }
        }