예제 #1
0
        /// <summary>
        /// Updates the database with the information for the specified playlist.
        /// </summary>
        /// <param name="playlist">A <see cref="MediaPlaylist" /> object that represents the playlist to be updated and the updated information for the playlist.</param>
        /// <param name="cancellationToken">A token to observe while waiting for the task to complete.</param>
        /// <returns>
        /// A task that represents the asynchronous operation.
        /// </returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public async Task UpdateAsync(MediaPlaylist playlist, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            if (playlist == null)
            {
                throw new ArgumentNullException(nameof(playlist));
            }

            if (playlist.DefaultList)
            {
                await SetDefaultAsync(playlist, cancellationToken);
            }
            _context.Update(playlist);
        }
예제 #2
0
        /// <summary>
        /// Sets the specified playlist as default playlist.
        /// </summary>
        /// <param name="playlist">A <see cref="MediaPlaylist" /> object that represents the playlist to be updated and the updated information for the playlist.</param>
        /// <param name="cancellationToken">A token to observe while waiting for the task to complete.</param>
        /// <returns>
        /// A task that represents the asynchronous operation.
        /// </returns>
        public async Task SetDefaultAsync(MediaPlaylist playlist, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            if (playlist == null)
            {
                throw new ArgumentNullException(nameof(playlist));
            }

            var defaultPlaylist = await FindDefaultByContactAsync(playlist.ContactId, cancellationToken);

            if (defaultPlaylist != null)
            {
                defaultPlaylist.DefaultList = false;
            }
            playlist.DefaultList = true;
        }