コード例 #1
0
        public IMovieLocationModel Update(IMovieLocationModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = MovieLocationsRepository.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 (MovieLocationMapper.AreEqual(model, existingEntity))
            {
                return(MovieLocationMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            MovieLocationMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            MovieLocationsRepository.Update(MovieLocationMapper.MapToEntity(model));
            // Try to Save Changes
            MovieLocationsRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
コード例 #2
0
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new MovieLocationMapper();
            var model  = MovieLocationsMockingSetup.DoMockingSetupForMovieLocationModel(1);
            var entity = MovieLocationsMockingSetup.DoMockingSetupForMovieLocation(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
コード例 #3
0
 public void Verify_AreEqual_WithEqualObjects_ReturnsTrue()
 {
     // Arrange
     var mapper = new MovieLocationMapper();
     var model = MovieLocationsMockingSetup.DoMockingSetupForMovieLocationModel(1);
     var entity = MovieLocationsMockingSetup.DoMockingSetupForMovieLocation(1);
     // Act
     var result = mapper.AreEqual(model.Object, entity.Object);
     // Assert
     Assert.True(result);
 }