コード例 #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);
     }
 }
コード例 #2
0
 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;
 }
コード例 #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;
        }
コード例 #4
0
 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);
 }
コード例 #5
0
 public void UpdateCountryWithInvalidInfo()
 {
     Country country = new Country(0, "Deutschland", "de.png");
     country = couS.CreateCountry(country.Name, country.FlagPath);
     country.Name = "123Land";
     couS.UpdateCountry(country);
 }
コード例 #6
0
        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;
        }
コード例 #7
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);
 }
コード例 #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 + ")");
     }
 }
コード例 #9
0
 public void UpdateCountry(Country country)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
ファイル: Country.cs プロジェクト: Ethon/mcflurry_simulator
 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;
 }
コード例 #11
0
ファイル: Country.cs プロジェクト: Ethon/mcflurry_simulator
 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;
 }
コード例 #12
0
ファイル: Country.cs プロジェクト: Ethon/mcflurry_simulator
 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;
 }
コード例 #13
0
ファイル: Country.cs プロジェクト: Ethon/mcflurry_simulator
 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;
 }
コード例 #14
0
 public void DeleteCountry(Country country)
 {
     countryService.DeleteCountry(country);
 }
コード例 #15
0
 private bool IsUsedCountry(Country country)
 {
     return aDao.CountArtistsOfCountry(country) > 0;
 }
コード例 #16
0
 public void UpdateCountry(Country country)
 {
     countryService.UpdateCountry(country);
 }
コード例 #17
0
ファイル: Artist.cs プロジェクト: Ethon/mcflurry_simulator
 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"]);
     }
 }