示例#1
0
        public IMovieStoryArcModel Update(IMovieStoryArcModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = MovieStoryArcsRepository.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 (MovieStoryArcMapper.AreEqual(model, existingEntity))
            {
                return(MovieStoryArcMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            MovieStoryArcMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            MovieStoryArcsRepository.Update(MovieStoryArcMapper.MapToEntity(model));
            // Try to Save Changes
            MovieStoryArcsRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
示例#2
0
        public IMovieStoryArcModel Create(IMovieStoryArcModel 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(MovieStoryArcMapper.MapToSearchModel(model));

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            MovieStoryArcsRepository.Add(newEntity);
            // Try to Save Changes
            MovieStoryArcsRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new MovieStoryArcMapper();
            var model  = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArcModel(1);
            var entity = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArc(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
        public void Verify_MapToModelLite_AssignsLiteOnlyMovieStoryArcProperties()
        {
            // Arrange
            var mapper = new MovieStoryArcMapper();
            var entity = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArc();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(entity.Object.MovieId, model.MovieId);
            Assert.Equal(entity.Object.StoryArcId, model.StoryArcId);
        }
        public void Verify_MapToEntity_AssignsMovieStoryArcProperties()
        {
            // Arrange
            var mapper = new MovieStoryArcMapper();
            var model  = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArcModel();
            // Act
            var entity = mapper.MapToEntity(model.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(model.Object.MovieId, entity.MovieId);
            Assert.Equal(model.Object.StoryArcId, entity.StoryArcId);
            // Associated Objects
            // <None>
        }
        public void Verify_MapToSearchModel_AssignsMovieStoryArcSearchProperties()
        {
            // Arrange
            var mapper = new MovieStoryArcMapper();
            var model  = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArcModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.MovieId, searchModel.MovieId);
            Assert.Equal(model.Object.Movie?.CustomKey, searchModel.MovieCustomKey);
            Assert.Equal(model.Object.Movie?.ApiDetailUrl, searchModel.MovieApiDetailUrl);
            Assert.Equal(model.Object.Movie?.SiteDetailUrl, searchModel.MovieSiteDetailUrl);
            Assert.Equal(model.Object.Movie?.Name, searchModel.MovieName);
            Assert.Equal(model.Object.Movie?.ShortDescription, searchModel.MovieShortDescription);
            Assert.Equal(model.Object.Movie?.Description, searchModel.MovieDescription);
            Assert.Equal(model.Object.StoryArcId, searchModel.StoryArcId);
            Assert.Equal(model.Object.StoryArc?.CustomKey, searchModel.StoryArcCustomKey);
            Assert.Equal(model.Object.StoryArc?.ApiDetailUrl, searchModel.StoryArcApiDetailUrl);
            Assert.Equal(model.Object.StoryArc?.SiteDetailUrl, searchModel.StoryArcSiteDetailUrl);
            Assert.Equal(model.Object.StoryArc?.Name, searchModel.StoryArcName);
            Assert.Equal(model.Object.StoryArc?.ShortDescription, searchModel.StoryArcShortDescription);
            Assert.Equal(model.Object.StoryArc?.Description, searchModel.StoryArcDescription);
        }
示例#7
0
 public IMovieStoryArcModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(MovieStoryArcMapper.MapToModel(MovieStoryArcsRepository.Get(key)));
 }
示例#8
0
 public IMovieStoryArcModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(MovieStoryArcMapper.MapToModel(MovieStoryArcsRepository.Get(id)));
 }
 public void Verify_MapToSearchModel_AssignsMovieStoryArcSearchProperties()
 {
     // Arrange
     var mapper = new MovieStoryArcMapper();
     var model = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArcModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.MovieId, searchModel.MovieId);
     Assert.Equal(model.Object.Movie?.CustomKey, searchModel.MovieCustomKey);
     Assert.Equal(model.Object.Movie?.ApiDetailUrl, searchModel.MovieApiDetailUrl);
     Assert.Equal(model.Object.Movie?.SiteDetailUrl, searchModel.MovieSiteDetailUrl);
     Assert.Equal(model.Object.Movie?.Name, searchModel.MovieName);
     Assert.Equal(model.Object.Movie?.ShortDescription, searchModel.MovieShortDescription);
     Assert.Equal(model.Object.Movie?.Description, searchModel.MovieDescription);
     Assert.Equal(model.Object.StoryArcId, searchModel.StoryArcId);
     Assert.Equal(model.Object.StoryArc?.CustomKey, searchModel.StoryArcCustomKey);
     Assert.Equal(model.Object.StoryArc?.ApiDetailUrl, searchModel.StoryArcApiDetailUrl);
     Assert.Equal(model.Object.StoryArc?.SiteDetailUrl, searchModel.StoryArcSiteDetailUrl);
     Assert.Equal(model.Object.StoryArc?.Name, searchModel.StoryArcName);
     Assert.Equal(model.Object.StoryArc?.ShortDescription, searchModel.StoryArcShortDescription);
     Assert.Equal(model.Object.StoryArc?.Description, searchModel.StoryArcDescription);
 }
 public void Verify_MapToModel_AssignsMovieStoryArcProperties()
 {
     // Arrange
     var mapper = new MovieStoryArcMapper();
     var entity = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArc();
     // Act
     var model = mapper.MapToModel(entity.Object);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(entity.Object.MovieId, model.MovieId);
     Assert.Equal(entity.Object.StoryArcId, model.StoryArcId);
     // Associated Objects
     // <None>
 }
 public void Verify_MapToEntity_WithExistingEntity_AssignsMovieStoryArcProperties()
 {
     // Arrange
     var mapper = new MovieStoryArcMapper();
     var model = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArcModel();
     // Act
     IMovieStoryArc existingEntity = new MovieStoryArc { Id = 1 };
     mapper.MapToEntity(model.Object, ref existingEntity);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(model.Object.MovieId, existingEntity.MovieId);
     Assert.Equal(model.Object.StoryArcId, existingEntity.StoryArcId);
     // Associated Objects
     // <None>
 }
 public void Verify_AreEqual_WithEqualObjects_ReturnsTrue()
 {
     // Arrange
     var mapper = new MovieStoryArcMapper();
     var model = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArcModel(1);
     var entity = MovieStoryArcsMockingSetup.DoMockingSetupForMovieStoryArc(1);
     // Act
     var result = mapper.AreEqual(model.Object, entity.Object);
     // Assert
     Assert.True(result);
 }