Exemplo n.º 1
0
        public IConceptModel Create(IConceptModel 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(ConceptMapper.MapToSearchModel(model));

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

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

            // Assert
            Assert.Equal(model.Object.PrimaryImageFileId, searchModel.PrimaryImageFileId);
            Assert.Equal(model.Object.PrimaryImageFile?.CustomKey, searchModel.PrimaryImageFileCustomKey);
            Assert.Equal(model.Object.PrimaryImageFile?.ApiDetailUrl, searchModel.PrimaryImageFileApiDetailUrl);
            Assert.Equal(model.Object.PrimaryImageFile?.SiteDetailUrl, searchModel.PrimaryImageFileSiteDetailUrl);
            Assert.Equal(model.Object.PrimaryImageFile?.Name, searchModel.PrimaryImageFileName);
            Assert.Equal(model.Object.PrimaryImageFile?.ShortDescription, searchModel.PrimaryImageFileShortDescription);
            Assert.Equal(model.Object.PrimaryImageFile?.Description, searchModel.PrimaryImageFileDescription);
            Assert.Equal(model.Object.FirstIssueAppearanceId, searchModel.FirstIssueAppearanceId);
            Assert.Equal(model.Object.FirstIssueAppearance?.CustomKey, searchModel.FirstIssueAppearanceCustomKey);
            Assert.Equal(model.Object.FirstIssueAppearance?.ApiDetailUrl, searchModel.FirstIssueAppearanceApiDetailUrl);
            Assert.Equal(model.Object.FirstIssueAppearance?.SiteDetailUrl, searchModel.FirstIssueAppearanceSiteDetailUrl);
            Assert.Equal(model.Object.FirstIssueAppearance?.Name, searchModel.FirstIssueAppearanceName);
            Assert.Equal(model.Object.FirstIssueAppearance?.ShortDescription, searchModel.FirstIssueAppearanceShortDescription);
            Assert.Equal(model.Object.FirstIssueAppearance?.Description, searchModel.FirstIssueAppearanceDescription);
        }
 public void Verify_MapToSearchModel_AssignsConceptSearchProperties()
 {
     // Arrange
     var mapper = new ConceptMapper();
     var model = ConceptsMockingSetup.DoMockingSetupForConceptModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.PrimaryImageFileId, searchModel.PrimaryImageFileId);
     Assert.Equal(model.Object.PrimaryImageFile?.CustomKey, searchModel.PrimaryImageFileCustomKey);
     Assert.Equal(model.Object.PrimaryImageFile?.ApiDetailUrl, searchModel.PrimaryImageFileApiDetailUrl);
     Assert.Equal(model.Object.PrimaryImageFile?.SiteDetailUrl, searchModel.PrimaryImageFileSiteDetailUrl);
     Assert.Equal(model.Object.PrimaryImageFile?.Name, searchModel.PrimaryImageFileName);
     Assert.Equal(model.Object.PrimaryImageFile?.ShortDescription, searchModel.PrimaryImageFileShortDescription);
     Assert.Equal(model.Object.PrimaryImageFile?.Description, searchModel.PrimaryImageFileDescription);
     Assert.Equal(model.Object.FirstIssueAppearanceId, searchModel.FirstIssueAppearanceId);
     Assert.Equal(model.Object.FirstIssueAppearance?.CustomKey, searchModel.FirstIssueAppearanceCustomKey);
     Assert.Equal(model.Object.FirstIssueAppearance?.ApiDetailUrl, searchModel.FirstIssueAppearanceApiDetailUrl);
     Assert.Equal(model.Object.FirstIssueAppearance?.SiteDetailUrl, searchModel.FirstIssueAppearanceSiteDetailUrl);
     Assert.Equal(model.Object.FirstIssueAppearance?.Name, searchModel.FirstIssueAppearanceName);
     Assert.Equal(model.Object.FirstIssueAppearance?.ShortDescription, searchModel.FirstIssueAppearanceShortDescription);
     Assert.Equal(model.Object.FirstIssueAppearance?.Description, searchModel.FirstIssueAppearanceDescription);
 }