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(); }