Exemple #1
0
        private async Task <List <PersonPoster> > GetMostFeaturedActorsPerGenre(List <string> collectionIds)
        {
            var movies   = _movieRepository.GetAll(collectionIds);
            var genreIds = _movieRepository.GetGenres(collectionIds);
            var genres   = _genreRepository.GetListByIds(genreIds);

            var list = new List <PersonPoster>();

            foreach (var genre in genres.OrderBy(x => x.Name))
            {
                var selectedMovies = movies.Where(x => x.MediaGenres.Any(y => y.GenreId == genre.Id));
                var personId       = selectedMovies
                                     .SelectMany(x => x.ExtraPersons)
                                     .Where(x => x.Type == Constants.Actor)
                                     .GroupBy(x => x.PersonId)
                                     .Select(group => new { Id = group.Key, Count = group.Count() })
                                     .OrderByDescending(x => x.Count)
                                     .Select(x => x.Id)
                                     .FirstOrDefault();

                var person = await _personService.GetPersonById(personId);

                list.Add(PosterHelper.ConvertToPersonPoster(person, genre.Name));
            }

            return(list);
        }
Exemple #2
0
        private async Task <PersonPoster> GetMostFeaturedWriter(List <string> collectionIds)
        {
            var personId = _movieRepository.GetMostFeaturedPerson(collectionIds, Constants.Writer);

            var person = await _personService.GetPersonById(personId);

            return(PosterHelper.ConvertToPersonPoster(person, Constants.Movies.MostFeaturedWriter));
        }