Example #1
0
        public IGenderModel Create(IGenderModel 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(GenderMapper.MapToSearchModel(model));

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            GendersRepository.Add(newEntity);
            // Try to Save Changes
            GendersRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
 public void Verify_MapToSearchModel_AssignsGenderSearchProperties()
 {
     // Arrange
     var mapper = new GenderMapper();
     var model  = GendersMockingSetup.DoMockingSetupForGenderModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
 }