public static MovieDto AsDto(this MovieDocument document) => new MovieDto { Id = document.Id, Title = document.Title, Description = document.Description, AgeRestriction = document.AgeRestriction, Length = document.Length, PremiereDate = document.PremiereDate, Genre = document.Genre.ToString(), Director = new PersonDto { FirstName = document.Director?.FirstName, LastName = document.Director?.LastName }, Stars = document.Stars?.Select(s => new PersonDto { FirstName = s.FirstName, LastName = s.LastName }), Ratings = document.Ratings?.Select(r => new RateDto { Comment = r.Comment, Value = r.Value }) };
public override string Execute() { var numberOfDocuments = 0; _elasticClient.Indices.Delete("movie"); _elasticClient.Indices.Create("movie", x => x.Map <MovieDocument>(mm => mm.Properties(p => p.Keyword(t => t.Name(n => n.Genres))))); foreach (var contentData in _contentLoader.GetAllChildren <MovieProduct>(_referenceConverter.GetRootLink())) { if (contentData is ISearch movieProduct) { var indexMove = new MovieDocument { Id = contentData.TheMovieDbId, Adult = movieProduct.Adult, BelongsToCollection = movieProduct.BelongsToCollection, Casts = movieProduct.Casts?.ToList() ?? new List <Cast>(), ContentLink = movieProduct.ContentLink, Crews = movieProduct.Crews?.ToList() ?? new List <Crew>(), Genres = movieProduct.Genres ?? "", OrginalLang = movieProduct.OrginalLang ?? "", OriginalTitle = movieProduct.OriginalTitle ?? "", Overview = movieProduct.Overview ?? "", Popularity = movieProduct.Popularity, Poster = movieProduct.Poster, ReleaseDate = movieProduct.ReleaseDate, SpokenLanguages = movieProduct.SpokenLanguages ?? "", Title = movieProduct.Title ?? "", VoteAverage = movieProduct.VoteAverage, VoteCount = movieProduct.VoteCount }; var indexResponse = _elasticClient.IndexDocument(indexMove); numberOfDocuments++; } } return($"Number of documents; {numberOfDocuments}"); }