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

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

            newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
            newEntity.UpdatedDate = null;
            newEntity.Active      = true;
            // Add it
            EpisodeObjectFirstAppearancesRepository.Add(newEntity);
            // Try to Save Changes
            EpisodeObjectFirstAppearancesRepository.SaveChanges();
            // Return the new value
            return(Get(newEntity.Id));
        }
        public void Verify_MapToSearchModel_AssignsEpisodeObjectFirstAppearanceSearchProperties()
        {
            // Arrange
            var mapper = new EpisodeObjectFirstAppearanceMapper();
            var model  = EpisodeObjectFirstAppearancesMockingSetup.DoMockingSetupForEpisodeObjectFirstAppearanceModel();
            // 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.ObjectId, searchModel.ObjectId);
            Assert.Equal(model.Object.Object?.CustomKey, searchModel.ObjectCustomKey);
            Assert.Equal(model.Object.Object?.ApiDetailUrl, searchModel.ObjectApiDetailUrl);
            Assert.Equal(model.Object.Object?.SiteDetailUrl, searchModel.ObjectSiteDetailUrl);
            Assert.Equal(model.Object.Object?.Name, searchModel.ObjectName);
            Assert.Equal(model.Object.Object?.ShortDescription, searchModel.ObjectShortDescription);
            Assert.Equal(model.Object.Object?.Description, searchModel.ObjectDescription);
        }
 public void Verify_MapToSearchModel_AssignsEpisodeObjectFirstAppearanceSearchProperties()
 {
     // Arrange
     var mapper = new EpisodeObjectFirstAppearanceMapper();
     var model = EpisodeObjectFirstAppearancesMockingSetup.DoMockingSetupForEpisodeObjectFirstAppearanceModel();
     // 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.ObjectId, searchModel.ObjectId);
     Assert.Equal(model.Object.Object?.CustomKey, searchModel.ObjectCustomKey);
     Assert.Equal(model.Object.Object?.ApiDetailUrl, searchModel.ObjectApiDetailUrl);
     Assert.Equal(model.Object.Object?.SiteDetailUrl, searchModel.ObjectSiteDetailUrl);
     Assert.Equal(model.Object.Object?.Name, searchModel.ObjectName);
     Assert.Equal(model.Object.Object?.ShortDescription, searchModel.ObjectShortDescription);
     Assert.Equal(model.Object.Object?.Description, searchModel.ObjectDescription);
 }