예제 #1
0
        public static FilmEntity MapToEntity(FilmDetailModel detailModel, IEntityFactory entityFactory)
        {
            var entity = (entityFactory ??= new EntityFactory()).Create <FilmEntity>(detailModel.Id);

            entity.Id           = detailModel.Id;
            entity.OriginalName = detailModel.OriginalName;
            entity.CzechName    = detailModel.CzechName;
            entity.Genre        = (GenreEnum)detailModel.Genre;
            entity.TitleFotoUrl = detailModel.TitleFotoUrl;
            entity.Country      = detailModel.Country;
            entity.Duration     = detailModel.Duration;
            entity.Description  = detailModel.Description;

            if (detailModel.Reviews != null)
            {
                entity.Reviews = detailModel.Reviews
                                 .Select(model => ReviewMapper.MapToEntity(model, entityFactory)).ToList();
            }

            if (detailModel.Actors != null)
            {
                entity.Actors = detailModel.Actors
                                .Select(model => ActedInFilmMapper.MapToEntity(model, entityFactory)).ToList();
            }

            if (detailModel.Directors != null)
            {
                entity.Directors = detailModel.Directors
                                   .Select(model => DirectedFilmMapper.MapToEntity(model, entityFactory)).ToList();
            }

            return(entity);
        }
예제 #2
0
        public static PersonEntity MapToEntity(PersonDetailModel detailModel, IEntityFactory entityFactory)
        {
            var entity = (entityFactory ??= new EntityFactory()).Create <PersonEntity>(detailModel.Id);

            entity.Id        = detailModel.Id;
            entity.FirstName = detailModel.FirstName;
            entity.LastName  = detailModel.LastName;
            entity.BirthDate = detailModel.BirthDate;
            entity.FotoUrl   = detailModel.FotoUrl;

            if (detailModel.DirectedFilms != null)
            {
                entity.DirectedFilms = detailModel.DirectedFilms
                                       .Select(model => DirectedFilmMapper.MapToEntity(model, entityFactory)).ToList();
            }

            if (detailModel.ActedInFilms != null)
            {
                entity.ActedInFilms = detailModel.ActedInFilms
                                      .Select(model => ActedInFilmMapper.MapToEntity(model, entityFactory)).ToList();
            }

            return(entity);
        }