예제 #1
0
        public async Task <Movie[]> GetMoviesFromApi()
        {
            var response = await _client.GetAsync("api/filmes");

            if (response.IsSuccessStatusCode)
            {
                var stringResult = await response.Content.ReadAsStringAsync();

                var rawMovies = JsonConvert
                                .DeserializeObject <Filme[]>(stringResult);

                var movies = rawMovies.Select(m => Filme.ConvertToMovie(m));
                return(movies.ToList().ToArray());
            }

            return(new List <Movie>().ToArray());
        }