示例#1
0
 public virtual void MapToEntity(IMovieModel model, ref IMovie entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Movie Properties
     entity.HasStaffReview   = model.HasStaffReview;
     entity.Distributor      = model.Distributor;
     entity.BoxOfficeRevenue = model.BoxOfficeRevenue;
     entity.TotalRevenue     = model.TotalRevenue;
     entity.Budget           = model.Budget;
     entity.Rating           = model.Rating;
     entity.ReleaseDate      = model.ReleaseDate;
     entity.RunTime          = model.RunTime;
     // Related Objects
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile   = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.MovieCharacters = model.MovieCharacters?.Where(i => i.Active).Select(MovieCharacterMapperExtensions.MapToEntity).ToList();
     entity.MovieConcepts   = model.MovieConcepts?.Where(i => i.Active).Select(MovieConceptMapperExtensions.MapToEntity).ToList();
     entity.MovieLocations  = model.MovieLocations?.Where(i => i.Active).Select(MovieLocationMapperExtensions.MapToEntity).ToList();
     entity.MovieObjects    = model.MovieObjects?.Where(i => i.Active).Select(MovieObjectMapperExtensions.MapToEntity).ToList();
     entity.MovieProducers  = model.MovieProducers?.Where(i => i.Active).Select(MovieProducerMapperExtensions.MapToEntity).ToList();
     entity.MovieStoryArcs  = model.MovieStoryArcs?.Where(i => i.Active).Select(MovieStoryArcMapperExtensions.MapToEntity).ToList();
     entity.MovieStudios    = model.MovieStudios?.Where(i => i.Active).Select(MovieStudioMapperExtensions.MapToEntity).ToList();
     entity.MovieTeams      = model.MovieTeams?.Where(i => i.Active).Select(MovieTeamMapperExtensions.MapToEntity).ToList();
     entity.MovieWriters    = model.MovieWriters?.Where(i => i.Active).Select(MovieWriterMapperExtensions.MapToEntity).ToList();
 }
示例#2
0
        public IMovieModel Create(IMovieModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateIDIsNull(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Search for an Existing Record (Don't allow Duplicates
            var results = Search(MovieMapper.MapToSearchModel(model));

            if (results.Any())
            {
                return(results.First());
            }                                              // Return the first that matches
            // Map model to a new entity
            var newEntity = MovieMapper.MapToEntity(model);

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            MoviesRepository.Add(newEntity);
            // Try to Save Changes
            MoviesRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
示例#3
0
        public IMovieModel Update(IMovieModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = MoviesRepository.Get(model.Id.Value);

            // Check if we would be applying identical information, if we are, just return the original
            // ReSharper disable once SuspiciousTypeConversion.Global
            if (MovieMapper.AreEqual(model, existingEntity))
            {
                return(MovieMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            MovieMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            MoviesRepository.Update(MovieMapper.MapToEntity(model));
            // Try to Save Changes
            MoviesRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
 public virtual void MapToEntity(IMovieModel model, ref IMovie entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Movie Properties
     entity.HasStaffReview = model.HasStaffReview;
     entity.Distributor = model.Distributor;
     entity.BoxOfficeRevenue = model.BoxOfficeRevenue;
     entity.TotalRevenue = model.TotalRevenue;
     entity.Budget = model.Budget;
     entity.Rating = model.Rating;
     entity.ReleaseDate = model.ReleaseDate;
     entity.RunTime = model.RunTime;
     // Related Objects
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     // Associated Objects
     entity.MovieCharacters = model.MovieCharacters?.Where(i => i.Active).Select(MovieCharacterMapperExtensions.MapToEntity).ToList();
     entity.MovieConcepts = model.MovieConcepts?.Where(i => i.Active).Select(MovieConceptMapperExtensions.MapToEntity).ToList();
     entity.MovieLocations = model.MovieLocations?.Where(i => i.Active).Select(MovieLocationMapperExtensions.MapToEntity).ToList();
     entity.MovieObjects = model.MovieObjects?.Where(i => i.Active).Select(MovieObjectMapperExtensions.MapToEntity).ToList();
     entity.MovieProducers = model.MovieProducers?.Where(i => i.Active).Select(MovieProducerMapperExtensions.MapToEntity).ToList();
     entity.MovieStoryArcs = model.MovieStoryArcs?.Where(i => i.Active).Select(MovieStoryArcMapperExtensions.MapToEntity).ToList();
     entity.MovieStudios = model.MovieStudios?.Where(i => i.Active).Select(MovieStudioMapperExtensions.MapToEntity).ToList();
     entity.MovieTeams = model.MovieTeams?.Where(i => i.Active).Select(MovieTeamMapperExtensions.MapToEntity).ToList();
     entity.MovieWriters = model.MovieWriters?.Where(i => i.Active).Select(MovieWriterMapperExtensions.MapToEntity).ToList();
 }
示例#5
0
            public void BindToViewModel(IMovieModel model)
            {
                ViewModel       = model;
                TitleLabel.Text = model.Dto.Title;

                Picasso.With(ImageView.Context)
                .Load(model.ImageUrl)
                .Config(Bitmap.Config.Rgb565)
                .Resize(512, 0)
                .OnlyScaleDown()
                //#if DEBUG
                //                .MemoryPolicy(MemoryPolicy.NoCache)
                //#endif
                .Into(ImageView);
            }
示例#6
0
 public virtual bool AreEqual(IMovieModel model, IMovie entity)
 {
     return(NameableEntityMapper.AreEqual(model, entity)
            // Movie Properties
            && model.HasStaffReview == entity.HasStaffReview &&
            model.Distributor == entity.Distributor &&
            model.BoxOfficeRevenue == entity.BoxOfficeRevenue &&
            model.TotalRevenue == entity.TotalRevenue &&
            model.Budget == entity.Budget &&
            model.Rating == entity.Rating &&
            model.ReleaseDate == entity.ReleaseDate &&
            model.RunTime == entity.RunTime
            // Related Objects
            && model.PrimaryImageFileId == entity.PrimaryImageFileId
            );
 }
 public virtual bool AreEqual(IMovieModel model, IMovie entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Movie Properties
         && model.HasStaffReview == entity.HasStaffReview
         && model.Distributor == entity.Distributor
         && model.BoxOfficeRevenue == entity.BoxOfficeRevenue
         && model.TotalRevenue == entity.TotalRevenue
         && model.Budget == entity.Budget
         && model.Rating == entity.Rating
         && model.ReleaseDate == entity.ReleaseDate
         && model.RunTime == entity.RunTime
         // Related Objects
         && model.PrimaryImageFileId == entity.PrimaryImageFileId
         ;
 }
示例#8
0
        public virtual IMovieSearchModel MapToSearchModel(IMovieModel model)
        {
            var searchModel = NameableEntityMapper.MapToSearchModel <IMovieModel, MovieSearchModel>(model);

            // Search Properties
            searchModel.PrimaryImageFileId               = model.PrimaryImageFileId;
            searchModel.PrimaryImageFileCustomKey        = model.PrimaryImageFile?.CustomKey;
            searchModel.PrimaryImageFileApiDetailUrl     = model.PrimaryImageFile?.ApiDetailUrl;
            searchModel.PrimaryImageFileSiteDetailUrl    = model.PrimaryImageFile?.SiteDetailUrl;
            searchModel.PrimaryImageFileName             = model.PrimaryImageFile?.Name;
            searchModel.PrimaryImageFileShortDescription = model.PrimaryImageFile?.ShortDescription;
            searchModel.PrimaryImageFileDescription      = model.PrimaryImageFile?.Description;
            searchModel.HasStaffReview = model.HasStaffReview;
            searchModel.Distributor    = model.Distributor;
            // Return Search Model
            return(searchModel);
        }
        public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var entity = MoviesMockingSetup.DoMockingSetupForMovie(1);
            var mockMoviesRepository = MoviesMockingSetup.DoMockingSetupForRepository();

            mockMoviesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object);
            var         businessWorkflow = new MoviesBusinessWorkflow(mockMoviesRepository.Object, new MovieMapper());
            var         model            = MoviesMockingSetup.DoMockingSetupForMovieModel(1);
            IMovieModel result           = null;

            // Act
            try { result = businessWorkflow.Update(model.Object); }
            catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
            // Assert
            Assert.NotNull(result);
            Assert.Equal("/TEST/KING-STEPHEN", result.ApiDetailUrl);
            Assert.Null(result.UpdatedDate);
        }
 public IMovieModel Create(IMovieModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateIDIsNull(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Search for an Existing Record (Don't allow Duplicates
     var results = Search(MovieMapper.MapToSearchModel(model));
     if (results.Any()) { return results.First(); } // Return the first that matches
     // Map model to a new entity
     var newEntity = MovieMapper.MapToEntity(model);
     newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
     newEntity.UpdatedDate = null;
     newEntity.Active = true;
     // Add it
     MoviesRepository.Add(newEntity);
     // Try to Save Changes
     MoviesRepository.SaveChanges();
     // Return the new value
     return Get(newEntity.Id);
 }
示例#11
0
 public static bool AreEqual(this IMovieModel model, IMovie entity)
 {
     return(Mapper.AreEqual(model, entity));
 }
示例#12
0
 public static IMovieSearchModel MapToSearchModel(this IMovieModel model)
 {
     return(Mapper.MapToSearchModel(model));
 }
示例#13
0
 public static void MapToEntity(this IMovieModel model, ref IMovie entity, int currentDepth = 1)
 {
     Mapper.MapToEntity(model, ref entity, currentDepth);
 }
示例#14
0
 public static IMovie MapToEntity(this IMovieModel model, int currentDepth = 1)
 {
     return(Mapper.MapToEntity(model, currentDepth));
 }
 public IMovieModel Update(IMovieModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Find existing entity
     // ReSharper disable once PossibleInvalidOperationException
     var existingEntity = MoviesRepository.Get(model.Id.Value);
     // Check if we would be applying identical information, if we are, just return the original
     // ReSharper disable once SuspiciousTypeConversion.Global
     if (MovieMapper.AreEqual(model, existingEntity))
     {
         return MovieMapper.MapToModel(existingEntity);
     }
     // Map model to an existing entity
     MovieMapper.MapToEntity(model, ref existingEntity);
     existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
     // Update it
     MoviesRepository.Update(MovieMapper.MapToEntity(model));
     // Try to Save Changes
     MoviesRepository.SaveChanges();
     // Return the new value
     return Get(existingEntity.Id);
 }
 public virtual IMovieSearchModel MapToSearchModel(IMovieModel model)
 {
     var searchModel = NameableEntityMapper.MapToSearchModel<IMovieModel, MovieSearchModel>(model);
     // Search Properties
     searchModel.PrimaryImageFileId = model.PrimaryImageFileId;
     searchModel.PrimaryImageFileCustomKey = model.PrimaryImageFile?.CustomKey;
     searchModel.PrimaryImageFileApiDetailUrl = model.PrimaryImageFile?.ApiDetailUrl;
     searchModel.PrimaryImageFileSiteDetailUrl = model.PrimaryImageFile?.SiteDetailUrl;
     searchModel.PrimaryImageFileName = model.PrimaryImageFile?.Name;
     searchModel.PrimaryImageFileShortDescription = model.PrimaryImageFile?.ShortDescription;
     searchModel.PrimaryImageFileDescription = model.PrimaryImageFile?.Description;
     searchModel.HasStaffReview = model.HasStaffReview;
     searchModel.Distributor = model.Distributor;
     // Return Search Model
     return searchModel;
 }