public IMovieCharacterModel Update(IMovieCharacterModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = MovieCharactersRepository.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 (MovieCharacterMapper.AreEqual(model, existingEntity))
            {
                return(MovieCharacterMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            MovieCharacterMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            MovieCharactersRepository.Update(MovieCharacterMapper.MapToEntity(model));
            // Try to Save Changes
            MovieCharactersRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
        public void Verify_MapToModel_AssignsMovieCharacterProperties()
        {
            // Arrange
            var mapper = new MovieCharacterMapper();
            var entity = MovieCharactersMockingSetup.DoMockingSetupForMovieCharacter();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(entity.Object.MovieId, model.MovieId);
            Assert.Equal(entity.Object.CharacterId, model.CharacterId);
            // Associated Objects
            // <None>
        }
 public IMovieCharacterModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(MovieCharacterMapper.MapToModel(MovieCharactersRepository.Get(key)));
 }
 public IMovieCharacterModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(MovieCharacterMapper.MapToModel(MovieCharactersRepository.Get(id)));
 }
 public void Verify_MapToModel_AssignsMovieCharacterProperties()
 {
     // Arrange
     var mapper = new MovieCharacterMapper();
     var entity = MovieCharactersMockingSetup.DoMockingSetupForMovieCharacter();
     // Act
     var model = mapper.MapToModel(entity.Object);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(entity.Object.MovieId, model.MovieId);
     Assert.Equal(entity.Object.CharacterId, model.CharacterId);
     // Associated Objects
     // <None>
 }