private async Task AddItemToPlaylist(ISubsonicModel item)
        {
            if (item.Type == SubsonicModelTypeEnum.Song || item.Type == SubsonicModelTypeEnum.Video)
            {
                var playlistItems   = new List <PlaylistItem>(new[] { await LoadPlaylistItem(item) });
                var addItemsMessage = new AddItemsMessage {
                    Queue = playlistItems
                };
                if (_playNextItem)
                {
                    _playNextItem = false;
                    addItemsMessage.StartPlaying = true;
                }

                EventAggregator.Publish(addItemsMessage);
            }
            else
            {
                var children = new List <ISubsonicModel>();
                switch (item.Type)
                {
                case SubsonicModelTypeEnum.Album:
                {
                    await
                    SubsonicService.GetAlbum(item.Id)
                    .WithErrorHandler(ErrorDialogViewModel)
                    .OnSuccess(result => children.AddRange(result.Songs))
                    .Execute();
                }

                break;

                case SubsonicModelTypeEnum.Artist:
                {
                    await
                    SubsonicService.GetArtist(item.Id)
                    .WithErrorHandler(ErrorDialogViewModel)
                    .OnSuccess(result => children.AddRange(result.Albums))
                    .Execute();
                }

                break;

                case SubsonicModelTypeEnum.MusicDirectory:
                {
                    await
                    SubsonicService.GetMusicDirectory(item.Id)
                    .WithErrorHandler(ErrorDialogViewModel)
                    .OnSuccess(result => children.AddRange(result.Children))
                    .Execute();
                }

                break;

                case SubsonicModelTypeEnum.Index:
                {
                    children.AddRange(((IndexItem)item).Artists);
                }

                break;

                case SubsonicModelTypeEnum.Folder:
                {
                    await
                    SubsonicService.GetIndex(item.Id)
                    .WithErrorHandler(ErrorDialogViewModel)
                    .OnSuccess(result => children.AddRange(result.Artists))
                    .Execute();
                }

                break;
                }

                foreach (var subsonicModel in children)
                {
                    await AddItemToPlaylist(subsonicModel);
                }
            }
        }
        public void GetIndex_Always_ReturnsAGetIndexResult()
        {
            var result = _subject.GetIndex(5);

            result.Should().BeOfType <GetIndexResult>();
        }
Beispiel #3
0
 protected override IServiceResultBase <IndexItem> GetResult(int id)
 {
     return(SubsonicService.GetIndex(id));
 }