Ejemplo n.º 1
0
        public IEpisodeConceptModel Update(IEpisodeConceptModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = EpisodeConceptsRepository.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 (EpisodeConceptMapper.AreEqual(model, existingEntity))
            {
                return(EpisodeConceptMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            EpisodeConceptMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            EpisodeConceptsRepository.Update(EpisodeConceptMapper.MapToEntity(model));
            // Try to Save Changes
            EpisodeConceptsRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
Ejemplo n.º 2
0
        public IEpisodeConceptModel Create(IEpisodeConceptModel 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(EpisodeConceptMapper.MapToSearchModel(model));

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            EpisodeConceptsRepository.Add(newEntity);
            // Try to Save Changes
            EpisodeConceptsRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
Ejemplo n.º 3
0
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new EpisodeConceptMapper();
            var model  = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConceptModel(1);
            var entity = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConcept(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
Ejemplo n.º 4
0
        public void Verify_MapToModelLite_AssignsLiteOnlyEpisodeConceptProperties()
        {
            // Arrange
            var mapper = new EpisodeConceptMapper();
            var entity = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConcept();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(entity.Object.EpisodeId, model.EpisodeId);
            Assert.Equal(entity.Object.ConceptId, model.ConceptId);
        }
Ejemplo n.º 5
0
        public void Verify_MapToEntity_AssignsEpisodeConceptProperties()
        {
            // Arrange
            var mapper = new EpisodeConceptMapper();
            var model  = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConceptModel();
            // Act
            var entity = mapper.MapToEntity(model.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(model.Object.EpisodeId, entity.EpisodeId);
            Assert.Equal(model.Object.ConceptId, entity.ConceptId);
            // Associated Objects
            // <None>
        }
Ejemplo n.º 6
0
        public void Verify_MapToSearchModel_AssignsEpisodeConceptSearchProperties()
        {
            // Arrange
            var mapper = new EpisodeConceptMapper();
            var model  = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConceptModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.EpisodeId, searchModel.EpisodeId);
            Assert.Equal(model.Object.Episode?.CustomKey, searchModel.EpisodeCustomKey);
            Assert.Equal(model.Object.Episode?.ApiDetailUrl, searchModel.EpisodeApiDetailUrl);
            Assert.Equal(model.Object.Episode?.SiteDetailUrl, searchModel.EpisodeSiteDetailUrl);
            Assert.Equal(model.Object.Episode?.Name, searchModel.EpisodeName);
            Assert.Equal(model.Object.Episode?.ShortDescription, searchModel.EpisodeShortDescription);
            Assert.Equal(model.Object.Episode?.Description, searchModel.EpisodeDescription);
            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);
        }
 public void Verify_MapToSearchModel_AssignsEpisodeConceptSearchProperties()
 {
     // Arrange
     var mapper = new EpisodeConceptMapper();
     var model = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConceptModel();
     // Act
     var searchModel = mapper.MapToSearchModel(model.Object);
     // Assert
     Assert.Equal(model.Object.EpisodeId, searchModel.EpisodeId);
     Assert.Equal(model.Object.Episode?.CustomKey, searchModel.EpisodeCustomKey);
     Assert.Equal(model.Object.Episode?.ApiDetailUrl, searchModel.EpisodeApiDetailUrl);
     Assert.Equal(model.Object.Episode?.SiteDetailUrl, searchModel.EpisodeSiteDetailUrl);
     Assert.Equal(model.Object.Episode?.Name, searchModel.EpisodeName);
     Assert.Equal(model.Object.Episode?.ShortDescription, searchModel.EpisodeShortDescription);
     Assert.Equal(model.Object.Episode?.Description, searchModel.EpisodeDescription);
     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);
 }
 public void Verify_MapToModel_AssignsEpisodeConceptProperties()
 {
     // Arrange
     var mapper = new EpisodeConceptMapper();
     var entity = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConcept();
     // Act
     var model = mapper.MapToModel(entity.Object);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(entity.Object.EpisodeId, model.EpisodeId);
     Assert.Equal(entity.Object.ConceptId, model.ConceptId);
     // Associated Objects
     // <None>
 }
 public void Verify_MapToEntity_WithExistingEntity_AssignsEpisodeConceptProperties()
 {
     // Arrange
     var mapper = new EpisodeConceptMapper();
     var model = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConceptModel();
     // Act
     IEpisodeConcept existingEntity = new EpisodeConcept { Id = 1 };
     mapper.MapToEntity(model.Object, ref existingEntity);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(model.Object.EpisodeId, existingEntity.EpisodeId);
     Assert.Equal(model.Object.ConceptId, existingEntity.ConceptId);
     // Associated Objects
     // <None>
 }
 public void Verify_AreEqual_WithEqualObjects_ReturnsTrue()
 {
     // Arrange
     var mapper = new EpisodeConceptMapper();
     var model = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConceptModel(1);
     var entity = EpisodeConceptsMockingSetup.DoMockingSetupForEpisodeConcept(1);
     // Act
     var result = mapper.AreEqual(model.Object, entity.Object);
     // Assert
     Assert.True(result);
 }
Ejemplo n.º 11
0
 public IEpisodeConceptModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(EpisodeConceptMapper.MapToModel(EpisodeConceptsRepository.Get(key)));
 }
Ejemplo n.º 12
0
 public IEpisodeConceptModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(EpisodeConceptMapper.MapToModel(EpisodeConceptsRepository.Get(id)));
 }