private async void LoadEpisode() { if (!LoadingActive) { LoadingActive = true; String id; String season; String episodeNr; NavigationContext.QueryString.TryGetValue("id", out id); NavigationContext.QueryString.TryGetValue("season", out season); NavigationContext.QueryString.TryGetValue("episode", out episodeNr); LayoutRoot.Opacity = 1; show = await showController.getShowByTVDBID(id); episode = await episodeController.getEpisodeByTvdbAndSeasonInfo(id, season, episodeNr, show); if (episode != null) { DateTime airTime = new DateTime(1970, 1, 1, 0, 0, 9, DateTimeKind.Utc); airTime = airTime.AddSeconds(episode.FirstAired); int daysSinceRelease = (DateTime.Now - airTime).Days; App.EpisodeViewModel.UpdateEpisodeView(episode, show); App.EpisodeViewModel.IsDataLoaded = true; LoadBackgroundImage(show); LoadScreenImage(episode); InitAppBar(); } LoadingActive = false; } }
private async void CheckinEpisode_Click(object sender, RoutedEventArgs e) { this.indicator = App.ShowLoading(this); lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; if (await episodeController.checkinEpisode(lastModel.Tvdb, lastModel.Name, lastModel.Year, lastModel.Season, lastModel.Episode)) { if (lastModel != null) { lastModel.Watched = true; } TraktShow show = await showController.getShowByTVDBID(lastModel.Tvdb); ShowWatchingNowShow(await episodeController.getEpisodeByTvdbAndSeasonInfo(lastModel.Tvdb, lastModel.Season, lastModel.Episode, show), show, DateTime.UtcNow); ToastNotification.ShowToast("Show", "Checked in!"); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; this.indicator.IsVisible = false; }
private async void CheckinEpisode_Click(object sender, RoutedEventArgs e) { this.progressBarLoading.Visibility = System.Windows.Visibility.Visible; lastModel = (ListItemViewModel)((MenuItem)sender).DataContext; App.TrackEvent("ViewShow", "Checkin context"); if (await episodeController.checkinEpisode(lastModel.Tvdb, App.ShowViewModel.Name, Int16.Parse(App.ShowViewModel.Year), lastModel.Season, lastModel.Episode)) { lastModel.Watched = true; TraktShow show = await showController.getShowByTVDBID(lastModel.Tvdb); try { App.MainPage.ShowWatchingNowShow(await episodeController.getEpisodeByTvdbAndSeasonInfo(lastModel.Tvdb, lastModel.Season, lastModel.Episode, show), show, DateTime.UtcNow); } catch (NullReferenceException) { } ToastNotification.ShowToast("Show", "Checked in!"); } else { ErrorManager.ShowConnectionErrorPopup(); } lastModel = null; this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed; }
private async void client_UploadRatingStringCompleted(object sender, UploadStringCompletedEventArgs e) { try { String jsonString = e.Result; if (type.Equals("movie")) { String imdb; Int16 rating = Int16.Parse(this.selector.DataSource.SelectedItem.ToString()); NavigationContext.QueryString.TryGetValue("imdb", out imdb); MovieController controller = new MovieController(); TraktMovie movie = await controller.getMovieByImdbId(imdb); movie.MyRatingAdvanced = rating; if (rating > 5) { movie.MyRating = "Loved"; } else { movie.MyRating = "Hated"; } controller.updateMovie(movie); } else if (type.Equals("show")) { String imdb; String tvdb; Int16 rating = Int16.Parse(this.selector.DataSource.SelectedItem.ToString()); NavigationContext.QueryString.TryGetValue("imdb", out imdb); NavigationContext.QueryString.TryGetValue("tvdb", out tvdb); ShowController controller = new ShowController(); TraktShow show = controller.getShowByIMDBID(imdb); if (show == null) { show = await controller.getShowByTVDBID(tvdb); } show.MyRatingAdvanced = rating; if (rating > 5) { show.MyRating = "Loved"; } else { show.MyRating = "Hated"; } if (App.ShowViewModel != null) { App.ShowViewModel.MyRating = "true"; App.ShowViewModel.MyRatingAdvanced = rating; } controller.updateShow(show); } else if (type.Equals("episode")) { String imdb; String tvdbId; String year; String title; String season; String episode; NavigationContext.QueryString.TryGetValue("imdb", out imdb); NavigationContext.QueryString.TryGetValue("tvdb", out tvdbId); NavigationContext.QueryString.TryGetValue("year", out year); NavigationContext.QueryString.TryGetValue("title", out title); NavigationContext.QueryString.TryGetValue("season", out season); NavigationContext.QueryString.TryGetValue("episode", out episode); Int16 rating = Int16.Parse(this.selector.DataSource.SelectedItem.ToString()); EpisodeController controller = new EpisodeController(); ShowController showController = new ShowController(); TraktShow show = await showController.getShowByTVDBID(tvdbId); TraktEpisode traktEpisode = await controller.getEpisodeByTvdbAndSeasonInfo(tvdbId, season, episode, show); traktEpisode.MyRatingAdvanced = rating; if (rating > 5) { traktEpisode.MyRating = "Loved"; } else { traktEpisode.MyRating = "Hated"; } if (controller.updateEpisode(traktEpisode)) { if (App.ShowViewModel != null && !String.IsNullOrEmpty(App.ShowViewModel.Tvdb) && App.ShowViewModel.Tvdb.Equals(show.tvdb_id)) { App.ShowViewModel.updateEpisode(traktEpisode); } if (App.EpisodeViewModel != null && !String.IsNullOrEmpty(App.EpisodeViewModel.Tvdb) && App.EpisodeViewModel.Tvdb.Equals(show.tvdb_id)) { App.EpisodeViewModel.MyRating = "true"; App.EpisodeViewModel.MyRatingAdvanced = rating; } } else { ErrorManager.ShowConnectionErrorPopup(); NavigationService.GoBack(); } } MessageBox.Show("Rated successfull."); } catch (WebException) { ErrorManager.ShowConnectionErrorPopup(); } catch (TargetInvocationException) { ErrorManager.ShowConnectionErrorPopup(); } NavigationService.GoBack(); }