Beispiel #1
0
        public IConceptAppearedInIssueModel Create(IConceptAppearedInIssueModel 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(ConceptAppearedInIssueMapper.MapToSearchModel(model));

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

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

            // Assert
            Assert.Equal(model.Object.ConceptId, searchModel.ConceptId);
            Assert.Equal(model.Object.Concept?.CustomKey, searchModel.ConceptCustomKey);
            Assert.Equal(model.Object.Concept?.ApiDetailUrl, searchModel.ConceptApiDetailUrl);
            Assert.Equal(model.Object.Concept?.SiteDetailUrl, searchModel.ConceptSiteDetailUrl);
            Assert.Equal(model.Object.Concept?.Name, searchModel.ConceptName);
            Assert.Equal(model.Object.Concept?.ShortDescription, searchModel.ConceptShortDescription);
            Assert.Equal(model.Object.Concept?.Description, searchModel.ConceptDescription);
            Assert.Equal(model.Object.AppearedInIssueId, searchModel.AppearedInIssueId);
            Assert.Equal(model.Object.AppearedInIssue?.CustomKey, searchModel.AppearedInIssueCustomKey);
            Assert.Equal(model.Object.AppearedInIssue?.ApiDetailUrl, searchModel.AppearedInIssueApiDetailUrl);
            Assert.Equal(model.Object.AppearedInIssue?.SiteDetailUrl, searchModel.AppearedInIssueSiteDetailUrl);
            Assert.Equal(model.Object.AppearedInIssue?.Name, searchModel.AppearedInIssueName);
            Assert.Equal(model.Object.AppearedInIssue?.ShortDescription, searchModel.AppearedInIssueShortDescription);
            Assert.Equal(model.Object.AppearedInIssue?.Description, searchModel.AppearedInIssueDescription);
        }
 public void Verify_MapToSearchModel_AssignsConceptAppearedInIssueSearchProperties()
 {
     // Arrange
     var mapper = new ConceptAppearedInIssueMapper();
     var model = ConceptAppearedInIssuesMockingSetup.DoMockingSetupForConceptAppearedInIssueModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.ConceptId, searchModel.ConceptId);
     Assert.Equal(model.Object.Concept?.CustomKey, searchModel.ConceptCustomKey);
     Assert.Equal(model.Object.Concept?.ApiDetailUrl, searchModel.ConceptApiDetailUrl);
     Assert.Equal(model.Object.Concept?.SiteDetailUrl, searchModel.ConceptSiteDetailUrl);
     Assert.Equal(model.Object.Concept?.Name, searchModel.ConceptName);
     Assert.Equal(model.Object.Concept?.ShortDescription, searchModel.ConceptShortDescription);
     Assert.Equal(model.Object.Concept?.Description, searchModel.ConceptDescription);
     Assert.Equal(model.Object.AppearedInIssueId, searchModel.AppearedInIssueId);
     Assert.Equal(model.Object.AppearedInIssue?.CustomKey, searchModel.AppearedInIssueCustomKey);
     Assert.Equal(model.Object.AppearedInIssue?.ApiDetailUrl, searchModel.AppearedInIssueApiDetailUrl);
     Assert.Equal(model.Object.AppearedInIssue?.SiteDetailUrl, searchModel.AppearedInIssueSiteDetailUrl);
     Assert.Equal(model.Object.AppearedInIssue?.Name, searchModel.AppearedInIssueName);
     Assert.Equal(model.Object.AppearedInIssue?.ShortDescription, searchModel.AppearedInIssueShortDescription);
     Assert.Equal(model.Object.AppearedInIssue?.Description, searchModel.AppearedInIssueDescription);
 }