Beispiel #1
0
        private async void LoadShow(String tvdb)
        {
            this.progressBarLoading.Visibility = System.Windows.Visibility.Visible;

            this.Show = await showController.getShowByTVDBID(tvdb);

            if (this.Show != null)
            {
                App.ShowViewModel.LoadData(tvdb);

                if (!String.IsNullOrEmpty(this.Show.GenresAsString))
                {
                    this.Show.Genres = this.Show.GenresAsString.Split('|');
                }

                App.ShowViewModel.UpdateShowView(this.Show);

                if (this.Show.Seasons.Count == 0)
                {
                    LoadSeasons(tvdb);
                }
                else
                {
                    App.ShowViewModel.NumberOfSeasons = (Int16)this.Show.Seasons.Count;
                }

                LoadBackgroundImage();
            }
            else
            {
                ErrorManager.ShowConnectionErrorPopup();
            }

            this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed;
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        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;
            }
        }
Beispiel #4
0
        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();
        }