Esempio n. 1
0
 public void DeleteCountry(Country country)
 {
     if (IsUsedCountry(country)) {
         throw new DataValidationException("Can't delete used country '" + country.Name + "'");
     }
     if (!couDao.DeleteCountry(country)) {
         throw new DatabaseException("DatabaseError: Can`t delete country " + country);
     }
 }
 public Artist CreateArtist(string name, string email, Category category, Country country, string picturePath, string videoPath)
 {
     Artist param = new Artist(0, name, email, category.Id, country.Id, picturePath, videoPath);
     var request = new RestRequest("api/Artist/CreateArtist", Method.POST);
     request.RequestFormat = DataFormat.Json;
     request.AddBody(param);
     Artist artist = client.Execute<Artist>(request).Data;
     if (artist != null)
     {
         foreach (var listener in listeners)
         {
             listener.OnArtistCreation(artist);
         }
     }
     return artist;
 }
Esempio n. 3
0
        public Artist CreateArtist(string name, string email, Category category, Country country, string picturePath, string videoPath)
        {
            if (!IsValidName(name)) {
                throw new DataValidationException("Can't create artist with invalid name '" + name + "'");
            } else if (!IsValidEmail(email)) {
                throw new DataValidationException("Can't create artist with invalid email address '" + email + "'");
            }  else if(category == null) {
                throw new DataValidationException("Can't create artist without category");
            } else if(country == null) {
                throw new DataValidationException("Can't create artist without country");
            } else if (!IsValidPicturePath(picturePath)) {
                throw new DataValidationException("Can`t create artist with invalid picturePath '" + picturePath + "'");
            } else if (!IsValidVideoPath(videoPath)) {
                throw new DataValidationException("Can`t create artist with invalid videoPath '" + videoPath + "'");
            }

            picturePath = picturePath == null ? "" : picturePath;
            videoPath = videoPath == null ? "" : videoPath;
            Artist artist = aDao.CreateArtist(name, email, category.Id, country.Id, picturePath, videoPath);
            foreach (var listener in listeners) {
                listener.OnArtistCreation(artist);
            }
            return artist;
        }
 public void UpdateCountryWithValidInfo()
 {
     Country country = new Country(0, "Deutschland", "de.png");
     country = couS.CreateCountry(country.Name, country.FlagPath);
     country.Name = "Frankreich";
     country.FlagPath = "fr.png";
     coudao.UpdateCountry(country);
 }
 public void UpdateCountryWithInvalidInfo()
 {
     Country country = new Country(0, "Deutschland", "de.png");
     country = couS.CreateCountry(country.Name, country.FlagPath);
     country.Name = "123Land";
     couS.UpdateCountry(country);
 }
        private Artist createTestArtistOfCountry(Country country)
        {
            Category categoryData = RepresentativeData.GetDefaultCategories()[0];
            Artist artistData = RepresentativeData.GetDefaultArtists()[0];

            Category category = catdao.CreateCategory(categoryData.Shortcut, categoryData.Name);
            Artist artist = adao.CreateArtist(artistData.Name, artistData.Email, category.Id, country.Id,
                artistData.PicturePath, artistData.VideoPath);
            return artist;
        }
 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);
 }
Esempio n. 8
0
 public void UpdateCountry(Country country)
 {
     if (!IsValidName(country.Name)) {
         throw new DataValidationException("Can't update country to invalid name '" + country.Name + "'");
     } else if (!IsValidFlagPath(country.FlagPath)) {
         throw new DataValidationException("Can't update country to invalid flagpath '" + country.FlagPath+ "'");
     }
     if (!couDao.UpdateCountry(country)) {
         throw new DatabaseException("Can`t update country with invalid ID: '" + country + ")");
     }
 }
 public void UpdateCountry(Country country)
 {
     throw new NotImplementedException();
 }
Esempio n. 10
0
 public bool UpdateCountry(Country country)
 {
     if (country != null) {
         DbCommand cmd = database.CreateCommand(SQL_UPDATE);
         database.DefineParameter(cmd, "@name", DbType.String, country.Name);
         database.DefineParameter(cmd, "@flagPath", DbType.String, country.FlagPath);
         database.DefineParameter(cmd, "@countryId", DbType.String, country.Id);
         return database.ExecuteNonQuery(cmd) >= 1;
     }
     return false;
 }
Esempio n. 11
0
 public Country GetCountryById(uint id)
 {
     DbCommand cmd = database.CreateCommand(SQL_FIND_BY_ID);
     database.DefineParameter(cmd, "@countryId", DbType.UInt32,id);
     Country country = null;
     database.doSynchronized(() => {
         using (IDataReader reader = database.ExecuteReader(cmd)) {
             if (reader.Read()) {
                 country = new Country((uint)reader["countryId"], (string)reader["name"], (string)reader["flagPath"]);
             }
         }
     });
     return country;
 }
Esempio n. 12
0
 public List<Country> GetAllCountries()
 {
     List<Country> countries = new List<Country>();
     DbCommand cmd = database.CreateCommand(SQL_FIND_ALL);
     database.doSynchronized(() => {
         using (IDataReader reader = database.ExecuteReader(cmd)) {
             while (reader.Read()) {
                 Country newCountry = new Country((uint)reader["countryId"], (string)reader["name"], (string)reader["flagPath"]);
                 countries.Add(newCountry);
             }
         }
     });
     return countries;
 }
Esempio n. 13
0
 public bool DeleteCountry(Country country)
 {
     if (country != null) {
         DbCommand cmd = database.CreateCommand(SQL_DELETE);
         database.DefineParameter(cmd, "@countryId", DbType.UInt32, country.Id);
         return database.ExecuteNonQuery(cmd) == 1;
     }
     return false;
 }
 public void DeleteCountry(Country country)
 {
     countryService.DeleteCountry(country);
 }
Esempio n. 15
0
 private bool IsUsedCountry(Country country)
 {
     return aDao.CountArtistsOfCountry(country) > 0;
 }
 public void UpdateCountry(Country country)
 {
     countryService.UpdateCountry(country);
 }
Esempio n. 17
0
 public uint CountArtistsOfCountry(Country country)
 {
     DbCommand cmd = database.CreateCommand(SQL_COUNTCOUNTRIES);
     database.DefineParameter(cmd, "@countryId", System.Data.DbType.UInt32, country.Id);
     using (DbDataReader reader = cmd.ExecuteReader()) {
         reader.Read();
         return (uint)((long)reader["count"]);
     }
 }