| 495 | | public void addPlaylists(List<PlaylistBase> thePlaylists, int libId) |
|---|
| 496 | | { |
|---|
| 497 | | throw new Exception("The method or operation is not implemented."); |
|---|
| | 502 | public void addPlaylists(List<PlaylistBase> thePlaylists) |
|---|
| | 503 | { |
|---|
| | 504 | List<IDbCommand> commandList = new List<IDbCommand>(); |
|---|
| | 505 | foreach (PlaylistBase thePlaylist in thePlaylists) |
|---|
| | 506 | { |
|---|
| | 507 | foreach (Int32 Song in thePlaylist.Songs) |
|---|
| | 508 | { |
|---|
| | 509 | IDbCommand command = this.databaseConnection.CreateCommand(); |
|---|
| | 510 | command.CommandText = @"INSERT INTO playlists |
|---|
| | 511 | (songId, playlistId, playlistName) values (?, ?, ?); |
|---|
| | 512 | SELECT last_insert_rowid();"; |
|---|
| | 513 | IDataParameter songId = command.CreateParameter(); |
|---|
| | 514 | songId.Value = Song.ToString(); |
|---|
| | 515 | command.Parameters.Add(songId); |
|---|
| | 516 | IDataParameter playlistId = command.CreateParameter(); |
|---|
| | 517 | playlistId.Value = thePlaylist.Id.ToString(); |
|---|
| | 518 | command.Parameters.Add(playlistId); |
|---|
| | 519 | IDataParameter playlistName = command.CreateParameter(); |
|---|
| | 520 | playlistName.Value = thePlaylist.Name; |
|---|
| | 521 | command.Parameters.Add(playlistName); |
|---|
| | 522 | commandList.Add(command); |
|---|
| | 523 | } |
|---|
| | 524 | } |
|---|
| | 525 | this.databaseConnection.Open(); |
|---|
| | 526 | foreach (IDbCommand command in commandList) |
|---|
| | 527 | { |
|---|
| | 528 | command.ExecuteNonQuery(); |
|---|
| | 529 | } |
|---|
| | 530 | this.databaseConnection.Close(); |
|---|
| | 531 | } |
|---|
| | 532 | |
|---|
| | 533 | public PlaylistBase loadPlaylist(int thePlaylistId) |
|---|
| | 534 | { |
|---|
| | 535 | PlaylistBase thePlaylist = new PlaylistBase(thePlaylistId); |
|---|
| | 536 | IDbCommand command = this.databaseConnection.CreateCommand(); |
|---|
| | 537 | command.CommandText = @"SELECT songId FROM playlists WHERE playlistId=($1)"; |
|---|
| | 538 | IDataParameter playlistId = command.CreateParameter(); |
|---|
| | 539 | playlistId.ParameterName = "$1"; |
|---|
| | 540 | playlistId.Value = thePlaylistId.ToString(); |
|---|
| | 541 | command.Parameters.Add(playlistId); |
|---|
| | 542 | this.databaseConnection.Open(); |
|---|
| | 543 | SQLiteDataReader result = (SQLiteDataReader)command.ExecuteReader(); |
|---|
| | 544 | while(result.Read()) |
|---|
| | 545 | { |
|---|
| | 546 | Int32 ret = result.GetInt32(0); |
|---|
| | 547 | thePlaylist.AddTrack(ret); |
|---|
| | 548 | } |
|---|
| | 549 | this.databaseConnection.Close(); |
|---|
| | 550 | return thePlaylist; |
|---|
| | 551 | } |
|---|
| | 552 | |
|---|
| | 553 | public void addPlaylist(PlaylistBase thePlaylist) |
|---|
| | 554 | { |
|---|
| | 555 | List<PlaylistBase> theList = new List<PlaylistBase>(); |
|---|
| | 556 | theList.Add(thePlaylist); |
|---|
| | 557 | addPlaylists(theList); |
|---|