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

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            EpisodePeopleRepository.Add(newEntity);
            // Try to Save Changes
            EpisodePeopleRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
Beispiel #2
0
        public void Verify_MapToSearchModel_AssignsEpisodePersonSearchProperties()
        {
            // Arrange
            var mapper = new EpisodePersonMapper();
            var model  = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePersonModel();
            // 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.PersonId, searchModel.PersonId);
            Assert.Equal(model.Object.Person?.CustomKey, searchModel.PersonCustomKey);
            Assert.Equal(model.Object.Person?.ApiDetailUrl, searchModel.PersonApiDetailUrl);
            Assert.Equal(model.Object.Person?.SiteDetailUrl, searchModel.PersonSiteDetailUrl);
            Assert.Equal(model.Object.Person?.Name, searchModel.PersonName);
            Assert.Equal(model.Object.Person?.ShortDescription, searchModel.PersonShortDescription);
            Assert.Equal(model.Object.Person?.Description, searchModel.PersonDescription);
        }
 public void Verify_MapToSearchModel_AssignsEpisodePersonSearchProperties()
 {
     // Arrange
     var mapper = new EpisodePersonMapper();
     var model = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePersonModel();
     // 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.PersonId, searchModel.PersonId);
     Assert.Equal(model.Object.Person?.CustomKey, searchModel.PersonCustomKey);
     Assert.Equal(model.Object.Person?.ApiDetailUrl, searchModel.PersonApiDetailUrl);
     Assert.Equal(model.Object.Person?.SiteDetailUrl, searchModel.PersonSiteDetailUrl);
     Assert.Equal(model.Object.Person?.Name, searchModel.PersonName);
     Assert.Equal(model.Object.Person?.ShortDescription, searchModel.PersonShortDescription);
     Assert.Equal(model.Object.Person?.Description, searchModel.PersonDescription);
 }