public Performance CreatePerformance(DateTime date, Artist artist, Venue venue)
 {
     Performance param = new Performance(0, date, artist.Id, venue.Id);
     var request = new RestRequest("api/Performance/CreatePerformance", Method.POST);
     request.RequestFormat = DataFormat.Json;
     request.AddBody(param);
     return client.Execute<Performance>(request).Data;
 }
 public ArtistViewModel(IArtistService artistService, ICategoryService categoryService,
     ICountryService countryService, Artist artist)
 {
     this.artistService = artistService;
     this.categoryService = categoryService;
     this.countryService = countryService;
     this.artist = artist;
 }
Example #3
0
 private string BuildMailBody(DateTime day, Artist artist, List<Performance> performances)
 {
     if (performances.Count == 0) {
         return "";
     }
     string bodyTemplate = File.ReadAllText(Config.Get().MailBodyTemplatePath);
     string itemTemplate = File.ReadAllText(Config.Get().MailBodyItemTemplatePath);
     return bodyTemplate.Replace(ARTIST_KEY, artist.Name)
                         .Replace(DATE_KEY, day.ToLongDateString())
                         .Replace(ITEMS_KEY, BuildMailBodyItems(itemTemplate, performances));
 }
 public void DeleteArtist(Artist artist)
 {
     var request = new RestRequest("api/Artist/DeleteArtist", Method.POST);
     request.RequestFormat = DataFormat.Json;
     request.AddBody(artist);
     client.Execute(request);
     foreach (var listener in listeners)
     {
         listener.OnArtistDeletion(artist);
     }
 }
 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 void DeleteArtist(Artist artist)
 {
     artistService.DeleteArtist(artist);
 }
 public Artist CreateArtist(Artist artist)
 {
     return artistService.CreateArtist(artist.Name, artist.Email, new Category(artist.CategoryId, null, null),
         new Country(artist.CountryId, null, null), artist.PicturePath, artist.VideoPath);
 }
Example #8
0
 public uint CountOfPerformancesOfArtist(Artist artist)
 {
     DbCommand cmd = db.CreateCommand(COUNTARTISTS_CMD);
     db.DefineParameter(cmd, "@artistId", System.Data.DbType.UInt32, artist.Id);
     uint count = 0;
     db.doSynchronized(() => {
         using (IDataReader reader = db.ExecuteReader(cmd)) {
             reader.Read();
             count = (uint)((long)reader["count"]);
         }
     });
     return count;
 }
 public void OnArtistUpdate(Artist artist)
 {
     PmVm.UpdateArtists();
 }
 public void OnArtistDeletion(Artist artist)
 {
     PmVm.UpdateArtists();
 }
 public void OnArtistCreation(Artist artist)
 {
     PmVm.UpdateArtists();
 }
Example #12
0
 public Artist GetArtistByName(string name)
 {
     DbCommand cmd = database.CreateCommand(SQL_FIND_BY_NAME);
     database.DefineParameter(cmd, "@name", DbType.String, name);
     Artist artist = null;
     database.doSynchronized(() => {
         using (IDataReader reader = database.ExecuteReader(cmd)) {
             if (reader.Read()) {
                 artist = new Artist((uint)reader["artistId"], (string)reader["name"], (string)reader["email"],
                     (uint)reader["categoryId"], (uint)reader["countryId"],
                     (string)reader["picturePath"], (string)reader["videoPath"]);
             }
         }
     });
     return artist;
 }
Example #13
0
 public bool DeleteArtist(Artist artist)
 {
     if (artist != null) {
         DbCommand cmd = database.CreateCommand(SQL_DELETE);
         database.DefineParameter(cmd, "@artistId", DbType.String, artist.Id);
         return database.ExecuteNonQuery(cmd) == 1;
     } else {
         return false;
     }
 }
Example #14
0
 public bool UpdateArtist(Artist artist)
 {
     if (artist != null) {
         DbCommand cmd = database.CreateCommand(SQL_UPDATE);
         database.DefineParameter(cmd, "@name", DbType.String, artist.Name);
         database.DefineParameter(cmd, "@email", DbType.String, artist.Email);
         database.DefineParameter(cmd, "@categoryId", DbType.UInt32, artist.CategoryId);
         database.DefineParameter(cmd, "@countryId", DbType.UInt32, artist.CountryId);
         database.DefineParameter(cmd, "@picturePath", DbType.String, artist.PicturePath);
         database.DefineParameter(cmd, "@videoPath", DbType.String, artist.VideoPath);
         database.DefineParameter(cmd, "@artistId", DbType.String, artist.Id);
         database.DefineParameter(cmd, "@deleted", DbType.Int16, artist.IsDeleted ? 1 : 0);
         return database.ExecuteNonQuery(cmd) >= 1;
     }
     return false;
 }
Example #15
0
 public bool MarkAsDeleted(Artist artist)
 {
     artist.IsDeleted = true;
     return UpdateArtist(artist);
 }
 public void UpdateArtist(Artist artist)
 {
     artistService.UpdateArtist(artist);
 }
Example #17
0
 public void UpdateArtist(Artist artist)
 {
     if (!IsValidName(artist.Name)) {
         throw new DataValidationException("Can't update artist to invalid name '" + artist.Name + "'");
     }
     if (!IsValidEmail(artist.Email)) {
         throw new DataValidationException("Can't update artist to invalid email '" + artist.Email + "'");
     }
     if (!IsValidPicturePath(artist.PicturePath)) {
         throw new DataValidationException("Can`t update artist with invalid picturePath '" + artist.PicturePath + "'");
     }
     if (!IsValidVideoPath(artist.VideoPath)) {
         throw new DataValidationException("Can`t update artist with invalid videoPath '" + artist.VideoPath + "'");
     }
     if (!aDao.UpdateArtist(artist)) {
         throw new DatabaseException("Can`t update artist with invalid ID: '" + artist + "'");
     }
     foreach (var listener in listeners) {
         listener.OnArtistUpdate(artist);
     }
 }
Example #18
0
 public void DeleteArtist(Artist artist)
 {
     var beforeNow = pDao.GetPerformancesByArtistBeforeDate(artist.Id, DateTime.Now);
     var afterNow = pDao.GetPerformancesByArtistAfterDate(artist.Id, DateTime.Now);
     if (beforeNow.Count >= 0) {
         if (!aDao.MarkAsDeleted(artist)) {
             throw new DatabaseException("Can`t delete artist with invalid ID: '" + artist + "'");
         }
     } else {
         if (!aDao.DeleteArtist(artist)) {
             throw new DatabaseException("Can`t delete artist with invalid ID: '" + artist + "'");
         }
     }
     foreach (var item in afterNow) {
         pDao.DeletePerformance(item);
     }
     foreach (var listener in listeners) {
         listener.OnArtistDeletion(artist);
     }
 }
Example #19
0
 public List<Artist> GetAllArtists()
 {
     List<Artist> artists = new List<Artist>();
     DbCommand cmd = database.CreateCommand(SQL_FIND_ALL);
     database.doSynchronized(() => {
         using (IDataReader reader = database.ExecuteReader(cmd)) {
             while (reader.Read()) {
                 Artist newArtist = new Artist((uint)reader["artistId"], (string)reader["name"],
                     (string)reader["email"], (uint)reader["categoryId"], (uint)reader["countryId"],
                     (string)reader["picturePath"], (string)reader["videoPath"]);
                 artists.Add(newArtist);
             }
         }
     });
     return artists;
 }