public int Compare(Song one, Song two) { if (one.Title.ToLower () == two.Title.ToLower ()) { if (one.Filename == two.Filename) return 0; } else { if (one.Filename == two.Filename) return 0; } return one.Filename.CompareTo (two.Filename); }
public int Compare(Song one, Song two) { return new SimpleSongComparer ().Compare(one, two); }
public abstract bool RemoveSong(Song song);
public abstract bool AddSong(Song song);
public bool RemoveSong(Song song) { SqliteCommand cmd = new SqliteCommand (); cmd.Connection = conn; cmd.CommandText = String.Format ("REMOVE FROM songs WHERE id = {0}", song.GetHashCode ()); int res = cmd.ExecuteNonQuery (); if (res > 0) return true; return false; }
public bool AddSong(Song song) { string artists = ArrayToSqlString (song.Artists); string performers = ArrayToSqlString (song.Performers); SqliteCommand cmd = new SqliteCommand (); cmd.Connection = conn; cmd.CommandText = String.Format ("INSERT INTO songs (id, filename, title, artists, performers, album, tracknumber, year, duration, mtime, gain) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}')", song.GetHashCode (), song.Filename, song.Title, artists, performers, song.Album, song.TrackNumber, song.Year, song.Duration, song.MTime, song.Gain); int res = cmd.ExecuteNonQuery (); if (res > 0) return true; return false; }