public void AddSongToHistoryList(SpotifyHistoryEntry entry) { ListViewItem item = new ListViewItem(entry.id.ToString()); item.SubItems.Add(entry.song.author); item.SubItems.Add(entry.song.name); item.SubItems.Add(entry.playTime.ToShortDateString() + " " + entry.playTime.ToShortTimeString()); this.historyListView.Items.Insert(0, item); }
public List<SpotifyHistoryEntry> GetHistoryEntries() { var list = new List<SpotifyHistoryEntry>(); var cmdHistoryExists = new SQLiteCommand("SELECT * FROM history", this.connection); var reader = cmdHistoryExists.ExecuteReader(); while (reader.Read()) { var entry = new SpotifyHistoryEntry(); var id = reader["id"].ToString(); if (id != null && id != "") { var song = Song.CreateFromTitle(reader["title"].ToString()); if(song != null) { entry.id = Convert.ToInt64(id); entry.song = song; entry.playTime = GetDatetimeFromUnix(Convert.ToDouble(reader["time"].ToString())); list.Add(entry); } } } return list; }