public void SetCheckboxCollection() { Playlists = new ObservableCollection <CheckingPlaylist>(); tempPlaylists = new ObservableCollection <CheckingPlaylist>(); foreach (var item in playlist) { bool isCheck = IsInPlaylist(item); CheckingPlaylist temp = new CheckingPlaylist(item, isCheck); CheckingPlaylist temp1 = new CheckingPlaylist(item, isCheck); Playlists.Add(temp); tempPlaylists.Add(temp1); } }
public void AddToPlaylist() { foreach (var newPlaylist in Playlists) { foreach (var oldPlayList in tempPlaylists) { if (newPlaylist.playlist.IdPlaylist == oldPlayList.playlist.IdPlaylist) { if (newPlaylist.isChecked == oldPlayList.isChecked) { break; } else if (newPlaylist.isChecked == false) { int id = context.PlaylistVideo.GetIfExist(newPlaylist.playlist.IdPlaylist, Video.IdVideo).IdPlaylistVideo; context.PlaylistVideo.Delete(id); } else { PlaylistVideo playlistvideo = new PlaylistVideo() { PlaylistId = newPlaylist.playlist.IdPlaylist, VideoId = Video.IdVideo }; context.PlaylistVideo.Create(playlistvideo); } break; } else { continue; } } } tempPlaylists = new ObservableCollection <CheckingPlaylist>(); foreach (var item in Playlists) { CheckingPlaylist check = new CheckingPlaylist(item.playlist, item.isChecked); tempPlaylists.Add(check); } IsOpenDialog = false; }