protected override Task <GetMoviesQueryResult> RunQueryAsync(GetMoviesQuery query) { var moviesRaw = _dbContext.ImdbMovie.Skip(query.PageIndex * 1000).Take(1000); var moviesResult = new List <ImdbMovieDto>(); foreach (var movie in moviesRaw) { moviesResult.Add(ImdbMovieDto.Create(movie.Id, movie.Title, movie.Url, movie.Keywords, movie.DatePublished, movie.Description)); } return(Task.FromResult(new GetMoviesQueryResult(moviesResult))); }
public static ImdbMovie CreateImdbMovie(ImdbMovieDto movieModel, List <Actor> actorsDb, List <Genre> genresDb, List <Director> directoresDb, List <Creator> creatorsDb) { var result = new ImdbMovie(movieModel.Name, movieModel.Url, movieModel.Duration, movieModel.Description, movieModel.DatePublished, movieModel.Keywords, new AggregateRating(movieModel.AggregateRating == null?0:movieModel.AggregateRating.RatingCount, movieModel.AggregateRating?.WorstRating, movieModel.AggregateRating?.BestRating, movieModel.AggregateRating?.RatingValue), new Review(movieModel.Review?.Name, movieModel.Review?.ReviewBody, movieModel.Review?.InLanguage, movieModel.Review?.DateCreated, new ItemReviewed(movieModel.Review?.ItemReviewed.Url), new Person(movieModel.Review?.Author?.Url, movieModel.Review?.Author?.Name), new ReviewRating(movieModel.Review?.ReviewRating?.WorstRating, movieModel.Review?.ReviewRating?.BestRating, movieModel.Review?.ReviewRating?.RatingValue))); var movieActors = new List <ActorImdbMovie>(); foreach (var actor in actorsDb) { movieActors.Add(new ActorImdbMovie { Actor = actor, ImdbMovie = result }); } var movieCreators = new List <CreatorImdbMovie>(); foreach (var creator in creatorsDb) { movieCreators.Add(new CreatorImdbMovie { Creator = creator, ImdbMovie = result }); } var movieDirectos = new List <DirectorMovie>(); foreach (var director in directoresDb) { movieDirectos.Add(new DirectorMovie { Director = director, ImdbMovie = result }); } var movieGenres = new List <GenreImdbMovie>(); foreach (var genre in genresDb) { movieGenres.Add(new GenreImdbMovie { Genre = genre, ImdbMovie = result }); } result.Actors = movieActors; result.Creators = movieCreators; result.Directors = movieDirectos; result.Genres = movieGenres; return(result); }