/// <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);
        }
Exemple #2
0
        public void TestFindAll()
        {
            IArtistDao     dao      = DALFactory.CreateArtistDao(DALFactory.CreateDatabase());
            IList <Artist> entities = dao.findAll();

            Assert.AreEqual(entities.Count, 3);
        }
Exemple #3
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));
        }
Exemple #4
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");
        }
        public bool CheckIsCatagoryInUse(Catagory catagory)
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            if (dao.findByProperty(typeof(Artist).GetProperty("Catagory"), catagory).Count() > 0)
            {
                return(true);
            }
            return(false);
        }
Exemple #6
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");
        }
Exemple #7
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);
        }
Exemple #9
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;
     }));
 }
        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 ");
            });
        }
Exemple #13
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);
        }
        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++;
            }
        }
Exemple #16
0
        public Artist QueryArtistById(string id)
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            return(dao.findByUniqueProperty(typeof(Artist).GetProperty("Email"), id));
        }
Exemple #17
0
        public IList <Artist> QueryArtists()
        {
            IArtistDao dao = DALFactory.CreateArtistDao(database);

            return(dao.findAllWithoutDeleted());
        }