Esempio n. 1
0
        public async Task <MovieRankResponse> GetMovieRank(string movieName, CancellationToken cancellationToken)
        {
            var movieResponses = await _movieRankRepository.GetMoviesRank(movieName, cancellationToken);

            if (movieResponses == null || !movieResponses.Any())
            {
                throw  new InvalidOperationException($"movieName '{movieName}' doesn't exist!");
            }

            var overallRanking = Math.Round(movieResponses.Select(r => r.Ranking).Average());

            return(new MovieRankResponse()
            {
                MovieName = movieName,
                OverallRanking = overallRanking
            });
        }