public void TestFindAll() { IDatabase db = DALFactory.CreateDatabase(); IVenueDao dao = DALFactory.CreateVenueDao(db); IList <Venue> entities = dao.findAll(); Assert.AreEqual(entities.Count, 2); }
public IList <Performance> QueryPerfomancesByVenue(int venueId) { IPerformanceDao dao = DALFactory.CreatePerformanceDao(database); IVenueDao venueDao = DALFactory.CreateVenueDao(database); Venue v = venueDao.findById(venueId); return(dao.findByProperty(typeof(Performance).GetProperty("Venue"), v)); }
public void TestFindById() { IDatabase db = DALFactory.CreateDatabase(); IVenueDao dao = DALFactory.CreateVenueDao(db); Venue v = dao.findById(1); Assert.AreEqual(v.Id, 1); Assert.AreEqual(v.Description, "Stage1"); }
public bool DeleteVenue(Venue venue) { if (!canDeleteVenue(venue)) { throw new ElementInUseException($"Can't delete Venue {venue.Description}. Venue is assigend in any Performance"); } IVenueDao dao = DALFactory.CreateVenueDao(database); return(dao.Delete(venue)); }
public Venue SaveVenue(Venue venue) { IVenueDao dao = DALFactory.CreateVenueDao(database); if (venue.Id != null && venue.Id > 0) { dao.Update(venue); return(venue); } venue = dao.Insert(venue); return(venue); }
public void TestUpdate() { IDatabase db = DALFactory.CreateDatabase(); IVenueDao dao = DALFactory.CreateVenueDao(db); Venue v = dao.findById(1); v.Description = "TEST-DESCRIPTION"; dao.Update(v); Venue result = dao.findById(1); Assert.AreEqual(result.Description, v.Description); }
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); }
public void TestInsert() { IDatabase db = DALFactory.CreateDatabase(); IVenueDao dao = DALFactory.CreateVenueDao(db); Venue v = new Venue(); v.Description = "UNIT-TEST"; v.Latitude = 2; v.Longitude = 2; v.ShortDescription = "NO"; v.Address = "TestAddress"; dao.Insert(v); Assert.AreEqual(dao.findAll().Count, 3); }
private static void CreateVenues() { Console.WriteLine("Insert Venues "); Random rand = new Random(); IVenueDao venueDao = DALFactory.CreateVenueDao(DALFactory.CreateDatabase()); for (int i = 1; i <= 60; i++) { Venue v = new Venue(); v.Address = "My Random Place " + i; v.Description = "This is Random Stage No " + i; v.ShortDescription = "Random Stage " + i; v.Latitude = (int)(48.30613 * 1000000); v.Longitude = (int)(14.286813 * 1000000); v.Latitude = v.Latitude + rand.Next(1, 100); v.Longitude = v.Longitude + rand.Next(1, 100); venueDao.Insert(v); } }
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); }
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); }
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++; } }
public IList <Venue> QueryVenues() { IVenueDao dao = DALFactory.CreateVenueDao(database); return(dao.findAll()); }