Esempio n. 1
0
        public static DatabaseArtistInfo FindOrCreate(DatabaseArtistInfo artist)
        {
            if (artist.Name == last_artist_name && last_artist != null)
            {
                return(last_artist);
            }

            if (String.IsNullOrEmpty(artist.Name) || artist.Name.Trim() == String.Empty)
            {
                artist.Name = null;
            }

            using (IDataReader reader = FindExistingArtists(artist.Name)) {
                if (reader.Read())
                {
                    last_artist = provider.Load(reader);
                    if (last_artist.NameSort != artist.NameSort)
                    {
                        last_artist.NameSort = artist.NameSort;
                        last_artist.Save();
                    }
                }
                else
                {
                    artist.Save();
                    last_artist = artist;
                }
            }

            last_artist_name = artist.Name;
            return(last_artist);
        }
Esempio n. 2
0
        public static DatabaseArtistInfo UpdateOrCreate(DatabaseArtistInfo artist)
        {
            DatabaseArtistInfo found = FindOrCreate(artist);

            if (found != artist)
            {
                // Overwrite the found artist
                artist.Name     = found.Name;
                artist.NameSort = found.NameSort;
                artist.dbid     = found.DbId;
                artist.Save();
            }
            return(artist);
        }
Esempio n. 3
0
 public static DatabaseArtistInfo UpdateOrCreate(DatabaseArtistInfo artist)
 {
     DatabaseArtistInfo found = FindOrCreate (artist);
     if (found != artist) {
         // Overwrite the found artist
         artist.Name = found.Name;
         artist.NameSort = found.NameSort;
         artist.MusicBrainzId = found.MusicBrainzId;
         artist.dbid = found.DbId;
         artist.Save ();
     }
     return artist;
 }
Esempio n. 4
0
        public static DatabaseArtistInfo FindOrCreate(DatabaseArtistInfo artist)
        {
            if (artist.Name == last_artist_name && last_artist != null) {
                return last_artist;
            }

            if (String.IsNullOrEmpty (artist.Name) || artist.Name.Trim () == String.Empty) {
                artist.Name = null;
            }

            using (IDataReader reader = FindExistingArtists (artist.Name)) {
                if (reader.Read ()) {
                    last_artist = provider.Load (reader);
                    bool save = false;
                    if (last_artist.NameSort != artist.NameSort) {
                        last_artist.NameSort = artist.NameSort;
                        save = true;
                    }
                    if (last_artist.MusicBrainzId != artist.MusicBrainzId && !String.IsNullOrEmpty (artist.MusicBrainzId)) {
                        last_artist.MusicBrainzId = artist.MusicBrainzId;
                        save = true;
                    }
                    if (save) {
                        last_artist.Save ();
                    }
                } else {
                    artist.Save ();
                    last_artist = artist;
                }
            }

            last_artist_name = artist.Name;
            return last_artist;
        }