private void AddShow() { var newShow = TvShow.NewTvShow(SeriesID); TvShows.Add(newShow); SelectedShow = newShow; }
private void AddTvShows(IEnumerable <string> tvShows) { foreach (string path in tvShows) { ITvShowViewModel newTvShow = _viewModelFactory.GetTvShow(path); TvShows.Add(newTvShow); } }
private async void LoadTvShowsAsync() { if (IsLoading) { return; } IsLoading = true; TvShows.Clear(); if (App.Context.Connection.Xbmc.IsMocked) { var videoDetailsTvShow = new VideoDetailsTvShow { TvShowId = 1, Title = "Saturday Night Live", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" } }; TvShows.Add(new ExtendedVideoDetailsTvShow(videoDetailsTvShow)); IsLoading = false; return; } try { var tvshows = await App.Context.Connection.Xbmc.VideoLibrary.GetTvShowsAsync( fields : new[] { VideoFieldsTVShow.art, VideoFieldsTVShow.title, VideoFieldsTVShow.plot, VideoFieldsTVShow.episode, VideoFieldsTVShow.watchedepisodes, VideoFieldsTVShow.playcount }); if (tvshows.TvShows == null || !tvshows.TvShows.Any()) { MessageBox.Show(AppResources.Page_Tv_Shows_Message_No_Tv_Show, AppResources.ApplicationTitle, MessageBoxButton.OK); if (NavigationService.CanGoBack) { NavigationService.GoBack(); } return; } var items = tvshows.TvShows.Where(s => _keepWatched || (!_keepWatched && !s.IsWatched)) .OrderBy(s => s.Label) .Select(s => new ExtendedVideoDetailsTvShow(s)); foreach (var extendedVideoDetailsTvShow in items) { TvShows.Add(extendedVideoDetailsTvShow); } } catch (Exception ex) { App.TrackException(ex); MessageBox.Show(AppResources.Global_Error_Message, AppResources.ApplicationTitle, MessageBoxButton.OK); } finally { IsLoading = false; } }
public async Task Load() { IsLoading = true; try { if (!TvShows.Any()) { IList <TvShow> tvShows = (await _tvShowService.GetTvShows()).ToList(); foreach (TvShow tvShow in tvShows.OrderBy(q => q.Name)) { TvShows.Add(tvShow); } } IList <TvShowEpisode> tvShowEpisodes = (await _tvShowService.GetContinueWatchingEpisodes()).ToList(); foreach (TvShowEpisode tvShowEpisode in tvShowEpisodes) { if (ContinueWatchingTvShows.All(q => q.Id != tvShowEpisode.Id)) { ContinueWatchingTvShows.Add(tvShowEpisode); TvShow correspondingTvShow = TvShows.FirstOrDefault(q => q.Id == tvShowEpisode.SeriesId); if (correspondingTvShow != null) { tvShowEpisode.TvShow = correspondingTvShow; TvShowSeason correspondingSeason = correspondingTvShow.Seasons.FirstOrDefault(q => q.Id == tvShowEpisode.SeasonId); if (correspondingSeason != null) { tvShowEpisode.Season = correspondingSeason; } else { IEnumerable <TvShowSeason> seasons = await _tvShowService.GetSeasonsBy(correspondingTvShow); correspondingSeason = seasons.FirstOrDefault(q => q.Id == tvShowEpisode.SeasonId); tvShowEpisode.Season = correspondingSeason; await _tvShowService.GetEpisodesBy(correspondingTvShow, correspondingSeason); } } } } OrderByName(); } catch (Exception xc) { _logManager.LogError(xc, "An error occurred while loading tv shows."); } finally { IsLoading = false; } }
private async Task LoadTvShowsAsync(bool keepWatched) { if (IsLoading) { return; } IsLoading = true; TvShows.Clear(); if (App.Context.Connection.Kodi.IsMocked) { var videoDetailsTvShow = new VideoDetailsTvShow { TvShowId = 1, Title = "Saturday Night Live", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" } }; TvShows.Add(new ExtendedVideoDetailsTvShow(videoDetailsTvShow)); IsLoading = false; return; } try { var tvshows = await App.Context.Connection.Kodi.VideoLibrary.GetTvShowsAsync( fields : new[] { VideoFieldsTVShow.art, VideoFieldsTVShow.title, VideoFieldsTVShow.plot, VideoFieldsTVShow.episode, VideoFieldsTVShow.watchedepisodes, VideoFieldsTVShow.playcount }); if (tvshows.TvShows == null || !tvshows.TvShows.Any()) { return; } var items = tvshows.TvShows.Where(s => keepWatched || (!keepWatched && !s.IsWatched)) .OrderBy(s => s.Label) .Select(s => new ExtendedVideoDetailsTvShow(s)); foreach (var extendedVideoDetailsTvShow in items) { TvShows.Add(extendedVideoDetailsTvShow); } } catch (Exception ex) { App.TrackException(ex); var dialog = new MessageDialog(_resourceLoader.GetString("GlobalErrorMessage"), _resourceLoader.GetString("ApplicationTitle")); await dialog.ShowAsync(); } finally { IsLoading = false; } }