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;
 }
        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 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);
 }
Beispiel #4
0
 public bool UpdateCategory(Category category)
 {
     if (category != null) {
         DbCommand cmd = database.CreateCommand(SQL_UPDATE);
         database.DefineParameter(cmd, "@shortcut", DbType.String, category.Shortcut);
         database.DefineParameter(cmd, "@name", DbType.String, category.Name);
         database.DefineParameter(cmd, "@categoryId", DbType.String, category.Id);
         return database.ExecuteNonQuery(cmd) >= 1;
     }
     return false;
 }
Beispiel #5
0
 public Category GetCategoryById(uint categoryId)
 {
     DbCommand cmd = database.CreateCommand(SQL_FIND_BY_ID);
     database.DefineParameter(cmd, "@categoryId", DbType.UInt32 , categoryId);
     Category cat = null;
     database.doSynchronized(() => {
         using (IDataReader reader = database.ExecuteReader(cmd)) {
             if (reader.Read()) {
                 cat = new Category((uint)reader["categoryId"], (string)reader["shortcut"],
                         (string)reader["name"]);
             }
         }
     });
     return cat;
 }
Beispiel #6
0
 public List<Category> GetAllCategories()
 {
     DbCommand cmd = database.CreateCommand(SQL_FIND_ALL);
     List <Category> categories = new List<Category>();
     database.doSynchronized(() => {
         using (IDataReader reader = database.ExecuteReader(cmd)) {
             while (reader.Read()) {
                 Category newCat = new Category((uint)reader["categoryId"], (string)reader["shortcut"], (string)reader["name"]);
                 categories.Add(newCat);
             }
         }
     });
     return categories;
 }
Beispiel #7
0
 public bool DeleteCategory(Category category)
 {
     if (category != null) {
         DbCommand cmd = database.CreateCommand(SQL_DELETE);
         database.DefineParameter(cmd, "@categoryId", DbType.UInt32,category.Id);
         return database.ExecuteNonQuery(cmd) == 1;
     }
     return false;
 }
Beispiel #8
0
 public uint CountArtistsOfCategory(Category category)
 {
     DbCommand cmd = database.CreateCommand(SQL_COUNTCATEGORIES);
     database.DefineParameter(cmd, "@categoryId", System.Data.DbType.UInt32, category.Id);
     using (DbDataReader reader = cmd.ExecuteReader()) {
         reader.Read();
         return (uint)((long)reader["count"]);
     }
 }