예제 #1
0
        public async Task Remove(Playlist playlist, IEnumerable <PlaylistItem> playlistItems)
        {
            using (var task = new RemoveItemsFromPlaylistTask(playlist, playlistItems))
            {
                task.InitializeComponent(this.Core);
                await this.OnBackgroundTask(task).ConfigureAwait(false);

                await task.Run().ConfigureAwait(false);
            }
        }
예제 #2
0
        public async Task Crop(IEnumerable <PlaylistItem> playlistItems)
        {
            using (var database = this.DatabaseFactory.Create())
            {
                using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
                {
                    var queryable = database.AsQueryable <PlaylistItem>(transaction);
                    var query     = queryable.Except(playlistItems);
                    //TODO: Bad .ToArray()
                    using (var task = new RemoveItemsFromPlaylistTask(query.ToArray()))
                    {
                        task.InitializeComponent(this.Core);
                        await this.OnBackgroundTask(task).ConfigureAwait(false);

                        await task.Run().ConfigureAwait(false);
                    }
                }
            }
        }
예제 #3
0
        public async Task Crop(Playlist playlist, IEnumerable <PlaylistItem> playlistItems)
        {
            using (var database = this.DatabaseFactory.Create())
            {
                using (var transaction = database.BeginTransaction(database.PreferredIsolationLevel))
                {
                    var queryable = database.AsQueryable <PlaylistItem>(transaction);
                    var query     = queryable.Where(
                        playlistItem => playlistItem.Playlist_Id == playlist.Id
                        ).Except(playlistItems);
                    //TODO: Warning: Buffering a potentially large sequence.
                    playlistItems = query.ToArray();
                }
            }
            using (var task = new RemoveItemsFromPlaylistTask(playlist, playlistItems))
            {
                task.InitializeComponent(this.Core);
                await this.OnBackgroundTask(task).ConfigureAwait(false);

                await task.Run().ConfigureAwait(false);
            }
        }