public IVolumeObjectModel Create(IVolumeObjectModel 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(VolumeObjectMapper.MapToSearchModel(model));

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            VolumeObjectsRepository.Add(newEntity);
            // Try to Save Changes
            VolumeObjectsRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
        public void Verify_MapToSearchModel_AssignsVolumeObjectSearchProperties()
        {
            // Arrange
            var mapper = new VolumeObjectMapper();
            var model  = VolumeObjectsMockingSetup.DoMockingSetupForVolumeObjectModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.VolumeId, searchModel.VolumeId);
            Assert.Equal(model.Object.Volume?.CustomKey, searchModel.VolumeCustomKey);
            Assert.Equal(model.Object.Volume?.ApiDetailUrl, searchModel.VolumeApiDetailUrl);
            Assert.Equal(model.Object.Volume?.SiteDetailUrl, searchModel.VolumeSiteDetailUrl);
            Assert.Equal(model.Object.Volume?.Name, searchModel.VolumeName);
            Assert.Equal(model.Object.Volume?.ShortDescription, searchModel.VolumeShortDescription);
            Assert.Equal(model.Object.Volume?.Description, searchModel.VolumeDescription);
            Assert.Equal(model.Object.ObjectId, searchModel.ObjectId);
            Assert.Equal(model.Object.Object?.CustomKey, searchModel.ObjectCustomKey);
            Assert.Equal(model.Object.Object?.ApiDetailUrl, searchModel.ObjectApiDetailUrl);
            Assert.Equal(model.Object.Object?.SiteDetailUrl, searchModel.ObjectSiteDetailUrl);
            Assert.Equal(model.Object.Object?.Name, searchModel.ObjectName);
            Assert.Equal(model.Object.Object?.ShortDescription, searchModel.ObjectShortDescription);
            Assert.Equal(model.Object.Object?.Description, searchModel.ObjectDescription);
        }
 public void Verify_MapToSearchModel_AssignsVolumeObjectSearchProperties()
 {
     // Arrange
     var mapper = new VolumeObjectMapper();
     var model = VolumeObjectsMockingSetup.DoMockingSetupForVolumeObjectModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.VolumeId, searchModel.VolumeId);
     Assert.Equal(model.Object.Volume?.CustomKey, searchModel.VolumeCustomKey);
     Assert.Equal(model.Object.Volume?.ApiDetailUrl, searchModel.VolumeApiDetailUrl);
     Assert.Equal(model.Object.Volume?.SiteDetailUrl, searchModel.VolumeSiteDetailUrl);
     Assert.Equal(model.Object.Volume?.Name, searchModel.VolumeName);
     Assert.Equal(model.Object.Volume?.ShortDescription, searchModel.VolumeShortDescription);
     Assert.Equal(model.Object.Volume?.Description, searchModel.VolumeDescription);
     Assert.Equal(model.Object.ObjectId, searchModel.ObjectId);
     Assert.Equal(model.Object.Object?.CustomKey, searchModel.ObjectCustomKey);
     Assert.Equal(model.Object.Object?.ApiDetailUrl, searchModel.ObjectApiDetailUrl);
     Assert.Equal(model.Object.Object?.SiteDetailUrl, searchModel.ObjectSiteDetailUrl);
     Assert.Equal(model.Object.Object?.Name, searchModel.ObjectName);
     Assert.Equal(model.Object.Object?.ShortDescription, searchModel.ObjectShortDescription);
     Assert.Equal(model.Object.Object?.Description, searchModel.ObjectDescription);
 }