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

            // Assert
            // <None>
            // Related Objects
            // <None>
            // Associated Objects
            Assert.Equal(entity.Object.OriginProfiles?.Count, model.OriginProfiles?.Count);
        }
コード例 #3
0
 public IProfileModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(ProfileMapper.MapToModel(ProfilesRepository.Get(key)));
 }
コード例 #4
0
 public IProfileModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(ProfileMapper.MapToModel(ProfilesRepository.Get(id)));
 }
コード例 #5
0
 public void Verify_MapToModel_AssignsProfileProperties()
 {
     // Arrange
     var mapper = new ProfileMapper();
     var entity = ProfilesMockingSetup.DoMockingSetupForProfile();
     // Act
     var model = mapper.MapToModel(entity.Object);
     // Assert
     // <None>
     // Related Objects
     // <None>
     // Associated Objects
     Assert.Equal(entity.Object.OriginProfiles?.Count, model.OriginProfiles?.Count);
 }