public IEnumerable <Movie> SearchMovies(string[] genres, string title, int yearOfRelease) { return(_movieRepository.SearchMovies(title, genres, yearOfRelease).Select(m => { var ratings = _movieRatingRepository.GetRatingsByMovieId(m.Id); m.AverageRating = ratings.Average(r => r.Rating); return m; })); }