//data mapper public static ICollection<INewsDto> MapINewsDtoToNewsCollection(ICollection<Movie> newss) { var result = new Collection<INewsDto>(); foreach (var item in newss) { var news = new NewsDto { MovieId = item.MovieId, OriginalTitle = item.OriginalTitle, RussianTitle = item.RussianTitle, Description = item.Description, ReleaseDate = item.ReleaseDate, Runtime = item.Runtime, PosterId = item.Posters.FirstOrDefault()?.PosterId ?? 0, Genres = new Collection<IGenreDto>() }; foreach (var genre in item.Genres) { news.Genres.Add(new GenreDto { Name = genre.Name }); } result.Add(news); } return result; }
public static INewsDto MapINewsDtoToNews(Movie movie) { var news = new NewsDto { MovieId = movie.MovieId, OriginalTitle = movie.OriginalTitle, RussianTitle = movie.RussianTitle, Description = movie.Description, ReleaseDate = movie.ReleaseDate, Runtime = movie.Runtime, PosterId = movie.Posters.FirstOrDefault()?.PosterId ?? 0, Genres = new Collection<IGenreDto>() }; foreach (var genre in movie.Genres) { news.Genres.Add(new GenreDto { Name = genre.Name }); } return news; }