Exemplo n.º 1
0
        public void TestFindAll()
        {
            IArtistDao     dao      = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            IList <Artist> entities = dao.findAll();

            Assert.AreEqual(entities.Count, 3);
        }
 public PerformanceService(DbConnection connection)
     : base(connection)
 {
     performanceDao = DaoFactory.CreatePerformanceDao(Connection);
     artistDao = DaoFactory.CreateArtistDao(Connection);
     venueDao = DaoFactory.CreateVenueDao(Connection);
 }
        /// <summary>
        /// disable an artist and set performances after now
        /// </summary>
        /// <param name="artist"></param>
        /// <returns></returns>
        public bool DeleteArtist(Artist artist)
        {
            IArtistDao dao      = DALFactory.CreateArtistDao(database);
            Artist     toDelete = dao.findById(artist.Id);

            if (toDelete == null)
            {
                return(false);
            }
            toDelete.Deleted = true;
            bool success = dao.Update(toDelete);

            if (success)
            {
                IPerformanceDao     performanceDao = DALFactory.CreatePerformanceDao(database);
                IList <Performance> performances   = performanceDao.FindPerformanceForArtistsAfterDate(toDelete, DateTime.Now);
                foreach (Performance p in performances)
                {
                    Console.WriteLine("found performances " + p.Id + "artist " + p.Artist.Name);
                    p.Canceld = true;
                    success   = performanceDao.Update(p);
                }
            }
            return(success);
        }
Exemplo n.º 4
0
        public IList <Performance> QueryPerfomancesByArtist(int artistId)
        {
            IPerformanceDao dao       = DALFactory.CreatePerformanceDao(database);
            IArtistDao      artistDao = DALFactory.CreateArtistDao(database);
            Artist          a         = artistDao.findById(artistId);

            return(dao.findByProperty(typeof(Performance).GetProperty("Artist"), a));
        }
 public static void ClassInitialize(TestContext testContext)
 {
     db = new MYSQLDatabase("Server = localhost; Database = ufotest; Uid = root;");
     catdao = new CategoryDao(db);
     coudao = new CountryDao(db);
     adao = new ArtistDao(db);
     couS = ServiceFactory.CreateCountryService(db);
 }
Exemplo n.º 6
0
        public void TestFindById()
        {
            IArtistDao dao    = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            Artist     artist = dao.findById(1);

            Assert.AreEqual(artist.Id, 1);
            Assert.AreEqual(artist.Name, "Larry Page");
        }
Exemplo n.º 7
0
 /// <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);
 }
Exemplo n.º 8
0
        void InsertDummyData(IArtistDao dao)
        {
            CreateTestData();

            foreach (var item in items)
            {
                dao.Insert(item);
            }
        }
Exemplo n.º 9
0
 public CountryService(IDatabase db)
 {
     if (db is MYSQLDatabase) {
         couDao = new CountryDao(db);
         aDao = new ArtistDao(db);
     } else {
         throw new NotSupportedException("Database not supported");
     }
 }
Exemplo n.º 10
0
        public void TestFindByUniqueProperty()
        {
            IArtistDao   dao    = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            PropertyInfo info   = typeof(Artist).GetProperty("Email");
            Artist       artist = dao.findByUniqueProperty(info, "*****@*****.**");

            Assert.AreEqual(artist.Id, 1);
            Assert.AreEqual(artist.Email, "*****@*****.**");
            Assert.AreEqual(artist.Name, "Larry Page");
        }
Exemplo n.º 11
0
 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 bool CheckIsCatagoryInUse(Catagory catagory)
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            if (dao.findByProperty(typeof(Artist).GetProperty("Catagory"), catagory).Count() > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 public ArtistService(IDatabase db)
 {
     if(db is MYSQLDatabase) {
         aDao = new ArtistDao(db);
         pDao = new PerformanceDao(db);
     } else {
         throw new NotSupportedException("Database not supported");
     }
     listeners = new List<IArtistListener>();
 }
Exemplo n.º 15
0
        public void TestUpdate()
        {
            IArtistDao dao    = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            Artist     artist = dao.findById(1);

            artist.Email = "*****@*****.**";
            dao.Update(artist);

            Artist result = dao.findById(1);

            Assert.AreEqual(result.Email, artist.Email);
        }
        public Artist SaveArtist(Artist artist)
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            if (artist.Id != null && artist.Id > 0)
            {
                dao.Update(artist);
                return(artist);
            }
            artist = dao.Insert(artist);
            return(artist);
        }
Exemplo n.º 17
0
        public void TestFindByIdAndCheckFetchCatagory()
        {
            IArtistDao dao    = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            Artist     artist = dao.findById(1);

            Assert.AreEqual(artist.Id, 1);
            Assert.AreEqual(artist.Name, "Larry Page");

            ICatagoryDao catDao = DALFactory.CreateCatagoryDao(DALFactory.CreateDatabase());
            Catagory     cat    = catDao.findById(1);

            Assert.AreEqual(artist.Catagory.Id, cat.Id);
        }
        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);
        }
 public Task <bool> CheckEmailIsAvailable(string email, Artist artist)
 {
     return(Task <bool> .Run(() =>
     {
         IArtistDao dao = DALFactory.CreateArtistDao(database);
         IList <Artist> artists = dao.findByProperty(typeof(Artist).GetProperty("Email"), email);
         if (artists != null && artists.Count > 0)
         {
             if (artists.Count == 1 && artists.First().Id == artist.Id)
             {
                 return true;
             }
             return false;
         }
         return true;
     }));
 }
Exemplo n.º 20
0
        private static void CreateArtists()
        {
            Console.WriteLine("Insert Artists ");
            Random       r = new Random();
            RootObject   generatedEntries = FetchPersons();
            IArtistDao   dao         = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            ICatagoryDao catagoryDao = DALFactory.CreateCatagoryDao(DALFactory.CreateDatabase());

            generatedEntries.results.ToList().ForEach(x => {
                Console.WriteLine(x.user.name.first);
                Artist artist   = new Artist();
                artist.Catagory = catagoryDao.findById(r.Next(1, 10));
                artist.Name     = x.user.name.first + " " + x.user.name.last;
                artist.Email    = x.user.email;
                artist.Country  = "AUT";
                artist.Picture  = GetBase64EncodedImageFromUrl(x.user.picture.thumbnail);
                dao.Insert(artist);
                Console.WriteLine("Inserted ");
            });
        }
        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);
        }
Exemplo n.º 22
0
        public void TestInsert()
        {
            PropertyInfo info   = typeof(Artist).GetProperty("Email");
            Artist       artist = new Artist();

            artist.Email   = "*****@*****.**";
            artist.Name    = "UnitTestArtist";
            artist.Link    = "I do not have any Link";
            artist.Country = "AUT";

            IArtistDao dao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());

            dao.Insert(artist);

            Artist result = dao.findByUniqueProperty(info, "*****@*****.**");

            Assert.AreEqual(result.Email, artist.Email);
            Assert.AreEqual(result.Name, artist.Name);
            Assert.AreEqual(result.Link, artist.Link);
            Assert.AreEqual(result.Country, artist.Country);
        }
Exemplo n.º 23
0
        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 ArtistService(DbConnection connection = null)
     : base(connection)
 {
     artistDao = DaoFactory.CreateArtistDao(Connection);
     performanceDao = DaoFactory.CreatePerformanceDao(Connection);
 }
Exemplo n.º 25
0
 public ArtistProcessDb()
 {
     //Получаем объект для работы с художниками в базе
     _artistDao = DaoFactory.GetArtistDao();
 }
 public ArtistService(IArtistDao artistDao, IArtistFactory artistFactory)
 {
     _artistDao = artistDao;
     _artistFactory = artistFactory;
 }
Exemplo n.º 27
0
 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);
 }
Exemplo n.º 28
0
        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);
            }
        }
Exemplo n.º 29
0
        public Artist QueryArtistById(string id)
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            return(dao.findByUniqueProperty(typeof(Artist).GetProperty("Email"), id));
        }
Exemplo n.º 30
0
        public IList <Artist> QueryArtists()
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            return(dao.findAllWithoutDeleted());
        }
Exemplo n.º 31
0
 public void MyTestInitialize()
 {
     aDao = DALFactory.CreateArtistDao(database);
 }
Exemplo n.º 32
0
 public void Startup()
 {
     adao = new ArtistDao(db);
     catDao = new CategoryDao(db);
     couDao = new CountryDao(db);
     pDao = new PerformanceDao(db);
     pDao.DeleteAllPerformances();
     adao.DeleteAllArtists();
     catDao.DeleteAllCategories();
     couDao.DeleteAllCountries();
     foreach (var item in RepresentativeData.GetDefaultCategories()) {
         catDao.CreateCategory(item.Shortcut, item.Name);
     }
     foreach (var item in RepresentativeData.GetDefaultCountries()) {
         couDao.CreateCountry(item.Name, item.FlagPath);
     }
 }
Exemplo n.º 33
0
 public ArtistService(IArtistDao artistDao, IArtistFactory artistFactory)
 {
     _artistDao     = artistDao;
     _artistFactory = artistFactory;
 }
        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();
        }