Ejemplo n.º 1
0
        public IOriginProfileModel Update(IOriginProfileModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = OriginProfilesRepository.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 (OriginProfileMapper.AreEqual(model, existingEntity))
            {
                return(OriginProfileMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            OriginProfileMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            OriginProfilesRepository.Update(OriginProfileMapper.MapToEntity(model));
            // Try to Save Changes
            OriginProfilesRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
        public void Verify_MapToModel_AssignsOriginProfileProperties()
        {
            // Arrange
            var mapper = new OriginProfileMapper();
            var entity = OriginProfilesMockingSetup.DoMockingSetupForOriginProfile();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(entity.Object.OriginId, model.OriginId);
            Assert.Equal(entity.Object.ProfileId, model.ProfileId);
            // Associated Objects
            // <None>
        }
Ejemplo n.º 3
0
 public IOriginProfileModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(OriginProfileMapper.MapToModel(OriginProfilesRepository.Get(key)));
 }
Ejemplo n.º 4
0
 public IOriginProfileModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(OriginProfileMapper.MapToModel(OriginProfilesRepository.Get(id)));
 }