private void ReadDataFiles() { using (WebClient webClient = new WebClient()) { string moviesJson = webClient.DownloadString("https://imdb-api.com/en/API/Top250Movies/k_81ggrpaf"); MoviesResult = Movies.FromJson(moviesJson); } using (WebClient webClient = new WebClient()) { string showsJson = webClient.DownloadString("https://imdb-api.com/en/API/Top250TVs/k_81ggrpaf"); ShowsResult = Shows.FromJson(showsJson); } if (MoviesResult.Items.Count == 0 && ShowsResult.Items.Count == 0) { ReadLocalFiles(); //since apis have limit of 100 reads per day } }
private void ReadDataFiles() { using (WebClient webClient = new WebClient()) { string moviesJson = webClient.DownloadString("https://imdb-api.com/en/API/Top250Movies/k_81ggrpaf"); MoviesResult = Movies.FromJson(moviesJson); } using (WebClient webClient = new WebClient()) { string showsJson = webClient.DownloadString("https://imdb-api.com/en/API/Top250TVs/k_81ggrpaf"); ShowsResult = Shows.FromJson(showsJson); } if (MoviesResult.Items.Count == 0 && ShowsResult.Items.Count == 0) { ReadLocalFiles(); //since apis have limit of 100 reads per day } RatingsList = new List <string>(); foreach (var i in MoviesResult.Items) { RatingsList.Add(i.ImDbRating); } RatingsList = RatingsList.Distinct().ToList(); RatingsList = RatingsList.OrderBy(x => x).ToList(); }