public async Task <IActionResult> Put([FromBody] Resources.UserPoints points) { List <Resources.Recommendation> recommendations = new List <Resources.Recommendation>(); (await genreRepository.GetAll()).Where(g => g.IdGenre == points.Genre.Id) .Join(movieDataRepository.GetAll().Result, g => g.IdMovieData, md => md.IdMovieData, (g, md) => md) .ToList().ForEach(movie => { Resources.Movie data = _mapper.Map <Resources.Movie>(movie); int score = ScoreHelper.GetRecommendationScore(points, data, movieDataRepository, reviewRepository); Resources.Recommendation temp = new Resources.Recommendation { Movie = data, Score = score }; recommendations.Add(temp); }); return(Ok(recommendations.OrderByDescending(val => val.Score).Take(10))); }
public static int GetRecommendationScore(Resources.UserPoints points, Resources.Movie movie, IMovieDataRepository movieDataRepository, IReviewRepository reviewRepository) { int imdb = movie.Imdb.GetValueOrDefault(); int ms = movie.MetaScore.GetValueOrDefault(); int com = ScoreHelper.GetMovieCommunityScore(movie.IdMovie.Value, reviewRepository); int platFav = 0; int pop = ScoreHelper.GetMoviePopularity(movie.IdMovie.Value, movieDataRepository, reviewRepository); if (movie.PlatFav) { platFav = 100; } int score = (imdb * points.Imdb / 100) + (ms * points.MetaScore / 100) + (com * points.Community / 100) + (platFav * points.PlatFav / 100) + (pop * points.Popularity / 100); return(score); }