public InsertArtist(SqlConnection connection, RSSListener.Data.Model.Artist artist) { if (connection == null) { throw new ArgumentNullException("connection"); } else if (connection.State != System.Data.ConnectionState.Open) { throw new Exception("connection's state is not open"); } else { conn = connection; this.artist = artist; } }
public RSSListener.Data.Model.Artist getArtistByName(string name, bool insertifnotfound = false) { RSSListener.Data.Model.Artist g = artists.getByName(name); if (g == null) { if (insertifnotfound) { RSSListener.SQL.Inserts.InsertArtist ig = new Inserts.InsertArtist(connection, new Data.Model.Artist(name, false)); ig.writeInformation(); g = ig.artist; } else { throw new Exception("Genre was not found and insertion flag is false"); } } return(g); }