Beispiel #1
0
        public override async void Execute(object parameter)
        {
            if (parameter is not PlaylistDto playlistDto)
            {
                return;
            }
            var window = new CreatePlaylistWindow(_editPlaylistTitle, _songLoader, playlistDto);

            bool?result = window.ShowDialog();

            if (!(result ?? false))
            {
                return;
            }
            int playlistDtoIndex = _playlistHolder.Playlists.IndexOf(playlistDto);
            var playlist         = await _playlistRepository.GetAsync(playlistDto.Id);

            playlist.Name = window.PlaylistName;
            playlistDto   = await ModifyPlaylistInDb(playlist, window.CheckedSongs.Select(s => s.Id), _playlistRepository.UpdateAsync);

            if (playlistDto is null)
            {
                return;
            }
            _playlistHolder.Playlists[playlistDtoIndex] = playlistDto;
            _playlistHolder.UIPlaylist = playlistDto;
            _playlistHolder.OnModifiedPlaylistList();
        }
Beispiel #2
0
        public override async void Execute(object parameter)
        {
            var  window = new CreatePlaylistWindow(_createPlaylistTitle, _songLoader);
            bool?result = window.ShowDialog();

            if (!(result ?? false))
            {
                return;
            }

            var playlist = new Playlist {
                Name = window.PlaylistName
            };
            var playlistDto = await ModifyPlaylistInDb(playlist, window.CheckedSongs.Select(s => s.Id), _playlistRepository.CreateAsync);

            if (playlistDto is null)
            {
                return;
            }
            _playlistHolder.Playlists.Add(playlistDto);
        }