示例#1
0
 public static SortService GetServiceInstance()
 {
     if (instance == null)
     {
         instance = new SortService();
     }
     return(instance);
 }
示例#2
0
        public List <Movie> GetAllMovies()
        {
            var client                 = new HttpClient();
            var sorter                 = new SortService();
            var resultSimple           = client.GetAsync("https://ithstenta2020.s3.eu-north-1.amazonaws.com/topp100.json").Result;
            var resultDetailed         = client.GetAsync("https://ithstenta2020.s3.eu-north-1.amazonaws.com/detailedMovies.json").Result;
            var movieListSimple        = JsonSerializer.Deserialize <List <Movie> >(new StreamReader(resultSimple.Content.ReadAsStream()).ReadToEnd());
            var movieListDetailed      = JsonSerializer.Deserialize <List <MovieDetailed> >(new StreamReader(resultDetailed.Content.ReadAsStream()).ReadToEnd());
            var detailedListSimplified = movieListDetailed.Select(x => new Movie
            {
                id    = x.id,
                title = x.title,
                rated = x.imdbRating.ToString(),
            }
                                                                  ).ToList();
            var mergedList = sorter.MergeTwoLists(movieListSimple, detailedListSimplified);

            return(mergedList);
        }