コード例 #1
0
        private async Task LoadMoviesAsync()
        {
            Indicator.IsVisible = true;
            Indicator.IsRunning = true;
            RESTService service = new RESTService();
            var         list    = await service.GetMovies();

            if (!list.HasError)
            {
                List <MovieViewModel> movies = new List <MovieViewModel>();
                foreach (var item in list.results)
                {
                    MovieViewModel movie = new MovieViewModel();
                    movie.Id          = item.id;
                    movie.MovieName   = item.title;
                    movie.MoviePoster = Helper.ImagePathHelper.GetFullImageURL(item.poster_path);
                    movie.Detail      = string.Format("Release Date {0}, {1}", item.release_date.ToString("dd/MM/yyyy"), GetMovieGenre(item.genre_ids));
                    movies.Add(movie);
                }
                listaMovies.ItemsSource = movies;
            }
            else
            {
                await DisplayAlert("Error", string.Format("An error occurred on the server: {0}", list.ErrorMessage), "OK");
            }
            Indicator.IsVisible = false;
            Indicator.IsRunning = false;
        }