Пример #1
0
 //Add the song to the selected playlist and close
 private void AddToPlaylist_Click(object sender, RoutedEventArgs e)
 {
     if (_mainWindow.SongDataGrid.SelectedItem != null && ChoosePlaylist.SelectedIndex != -1)
     {
         Song     SelectedSong     = (Song)_mainWindow.SongDataGrid.SelectedItem;
         Playlist SelectedPlaylist = (Playlist)ChoosePlaylist.SelectedItem;
         _sqlAccess.AddSongToPlaylist(SelectedSong.S_Id, SelectedPlaylist.P_Id);
         Dispatcher.BeginInvoke(new Action(delegate()
         {
             _songList = _sqlAccess.GetSongsForUser(_userId);
             _mainWindow.SongDataGrid.ItemsSource = _songList;
             _playlistList = _sqlAccess.GetPlaylistsForUser(_userId);
             _mainWindow.PlaylistBox.ItemsSource = _playlistList;
         }));
         this.Close();
     }
 }