Пример #1
0
        private void RefreshByShowId(long showId, int selectedSeason = 1)
        {
            IsLoading = true;

            _tvshowtimeApiService.GetShow(showId, string.Empty, true)
            .Subscribe(async(showResponse) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    LastLoadingDate = DateTime.Now;

                    Seasons.Clear();

                    Show = showResponse.Show;
                    RaisePropertyChanged(nameof(Show));

                    foreach (var episode in Show.Episodes)
                    {
                        var seasonGroup = Seasons.FirstOrDefault(s => s.SeasonNumber == episode.Season);
                        if (seasonGroup == null)
                        {
                            seasonGroup = new ShowSeasonGroup {
                                SeasonNumber = episode.Season
                            };
                            Seasons.Add(seasonGroup);
                        }

                        seasonGroup.Episodes.Add(episode);
                    }

                    RaisePropertyChanged(nameof(MinSeasonNumber));
                    RaisePropertyChanged(nameof(MaxSeasonNumber));

                    SelectedSeason = Seasons.FirstOrDefault(s => s.SeasonNumber == selectedSeason);

                    IsLoading = false;
                });
            },
                       async(error) =>
            {
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    IsLoading = false;
                });

                _toastNotificationService.ShowErrorNotification("An error happened. Please retry later.");
            });
        }
Пример #2
0
 private void RefreshByShowId(long showId)
 {
     _tvshowtimeApiService.GetShow(showId, string.Empty, false)
     .Subscribe(async(showResponse) =>
     {
         await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
         {
             Show = showResponse.Show;
             RaisePropertyChanged(nameof(Show));
         });
     },
                (error) =>
     {
         throw new Exception();
     });
 }