public PerformanceService(DbConnection connection) : base(connection) { performanceDao = DaoFactory.CreatePerformanceDao(Connection); artistDao = DaoFactory.CreateArtistDao(Connection); venueDao = DaoFactory.CreateVenueDao(Connection); }
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)); }
/// <summary> /// Initializes a new instance of the <see cref="ViewerImpl"/> class. /// </summary> public ViewerImpl() { userDao = DalFactory.CreateUserDao(database); artistDao = DalFactory.CreateArtistDao(database); venueDao = DalFactory.CreateVenueDao(database); performanceDao = DalFactory.CreatePerformanceDao(database); categoryDao = DalFactory.CreateCategoryDao(database); }
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"); }
void InsertDummyData(IVenueDao dao) { CreateTestData(); foreach (var item in items) { dao.Insert(item); } }
public Commander(IDatabase database) { this.database = database; this.artistDao = DALFactory.CreateArtistDao(database); this.categoryDao = DALFactory.CreateCategoryDao(database); this.countryDao = DALFactory.CreateCountryDao(database); this.performanceDao = DALFactory.CreatePerformanceDao(database); this.userDao = DALFactory.CreateUserDao(database); this.venueDao = DALFactory.CreateVenueDao(database); }
public VenueService(IDatabase db) { if (db is MYSQLDatabase) { vdao = new VenueDao(db); pdao = new PerformanceDao(db); } else { throw new NotSupportedException("Database not supported"); } listeners = new List<IVenueListener>(); }
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 ManagerImpl() { database = DalFactory.CreateDatabase(); userDao = DalFactory.CreateUserDao(database); artistDao = DalFactory.CreateArtistDao(database); categoryDao = DalFactory.CreateCategoryDao(database); locationDao = DalFactory.CreateLocationDao(database); venueDao = DalFactory.CreateVenueDao(database); performanceDao = DalFactory.CreatePerformanceDao(database); }
public static void ClassInitialize(TestContext testContext) { db = new MYSQLDatabase("Server = localhost; Database = ufotest; Uid = root;"); vdao = new VenueDao(db); catdao = new CategoryDao(db); coudao = new CountryDao(db); adao = new ArtistDao(db); pdao = new PerformanceDao(db); vs = ServiceFactory.CreateVenueService(db); }
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 VenueService(DbConnection connection = null) : base(connection) { venueDao = DaoFactory.CreateVenueDao(connection); }
public void MyTestInitialize() { vDao = DALFactory.CreateVenueDao(database); }
public void Startup() { catdao = new CategoryDao(db); coudao = new CountryDao(db); adao = new ArtistDao(db); vdao = new VenueDao(db); pdao = new PerformanceDao(db); aS = ServiceFactory.CreateArtistService(db); category = RepresentativeData.GetDefaultCategories()[0]; country = RepresentativeData.GetDefaultCountries()[0]; category = catdao.CreateCategory(category.Shortcut, category.Name); country = coudao.CreateCountry(country.Name, country.FlagPath); }
public void Startup() { vdao = new VenueDao(db); catDao = new CategoryDao(db); couDao = new CountryDao(db); adao = new ArtistDao(db); pdao = new PerformanceDao(db); pdao.DeleteAllPerformances(); vdao.DeleteAllVenues(); adao.DeleteAllArtists(); catDao.DeleteAllCategories(); couDao.DeleteAllCountries(); foreach (var item in RepresentativeData.GetDefaultVenues()) { vdao.CreateVenue(item.Name, item.Shortcut, item.Latitude, item.Longitude); } foreach (var item in RepresentativeData.GetDefaultCategories()) { catDao.CreateCategory(item.Shortcut, item.Name); } foreach (var item in RepresentativeData.GetDefaultCountries()) { couDao.CreateCountry(item.Name, item.FlagPath); } foreach (var item in RepresentativeData.GetDefaultArtists()) { adao.CreateArtist(item.Name, item.Email, item.CategoryId, item.CountryId, item.PicturePath, item.VideoPath); } }
public void Startup() { pdao = new PerformanceDao(db); adoa = new ArtistDao(db); countrydao = new CountryDao(db); categorydao = new CategoryDao(db); vdao = new VenueDao(db); ps = ServiceFactory.CreatePerformanceService(db); pdao.DeleteAllPerformances(); adoa.DeleteAllArtists(); countrydao.DeleteAllCountries(); categorydao.DeleteAllCategories(); vdao.DeleteAllVenues(); }
public void Startup() { vdao = new VenueDao(db); }
public IList <Venue> QueryVenues() { IVenueDao dao = DALFactory.CreateVenueDao(database); return(dao.findAll()); }