コード例 #1
0
 public virtual bool AreEqual(IConceptModel model, IConcept entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Concept Properties
         && model.StartYear == entity.StartYear
         // Related Objects
         && model.PrimaryImageFileId == entity.PrimaryImageFileId
         && model.FirstIssueAppearanceId == entity.FirstIssueAppearanceId
         ;
 }
コード例 #2
0
 public virtual void MapToEntity(IConceptModel model, ref IConcept entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Concept Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance = (Issue)model.FirstIssueAppearance?.MapToEntity();
     // Associated Objects
     entity.ConceptAliases = model.ConceptAliases?.Where(i => i.Active).Select(ConceptAliasMapperExtensions.MapToEntity).ToList();
     entity.ConceptIssuesAppearedIn = model.ConceptIssuesAppearedIn?.Where(i => i.Active).Select(ConceptAppearedInIssueMapperExtensions.MapToEntity).ToList();
     entity.ConceptIssues = model.ConceptIssues?.Where(i => i.Active).Select(ConceptIssueMapperExtensions.MapToEntity).ToList();
     entity.ConceptMovies = model.ConceptMovies?.Where(i => i.Active).Select(ConceptMovieMapperExtensions.MapToEntity).ToList();
     entity.ConceptVolumes = model.ConceptVolumes?.Where(i => i.Active).Select(ConceptVolumeMapperExtensions.MapToEntity).ToList();
 }
コード例 #3
0
 public virtual IConcept MapToEntity(IConceptModel model, int currentDepth = 1)
 {
     currentDepth++;
     var entity = NameableEntityMapper.MapToEntity<Concept, IConceptModel>(model);
     // Concept Properties
     entity.StartYear = model.StartYear;
     // Related Objects
     entity.PrimaryImageFileId = model.PrimaryImageFileId;
     entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity();
     entity.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     entity.FirstIssueAppearance = (Issue)model.FirstIssueAppearance?.MapToEntity();
     // Associated Objects
     entity.ConceptAliases = model.ConceptAliases?.Where(i => i.Active).Select(ConceptAliasMapperExtensions.MapToEntity).Cast<ConceptAlias>().ToList();
     entity.ConceptIssuesAppearedIn = model.ConceptIssuesAppearedIn?.Where(i => i.Active).Select(ConceptAppearedInIssueMapperExtensions.MapToEntity).Cast<ConceptAppearedInIssue>().ToList();
     entity.ConceptIssues = model.ConceptIssues?.Where(i => i.Active).Select(ConceptIssueMapperExtensions.MapToEntity).Cast<ConceptIssue>().ToList();
     entity.ConceptMovies = model.ConceptMovies?.Where(i => i.Active).Select(ConceptMovieMapperExtensions.MapToEntity).Cast<ConceptMovie>().ToList();
     entity.ConceptVolumes = model.ConceptVolumes?.Where(i => i.Active).Select(ConceptVolumeMapperExtensions.MapToEntity).Cast<ConceptVolume>().ToList();
     // Return Entity
     return entity;
 }
コード例 #4
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);
 }
コード例 #5
0
 public virtual IConceptSearchModel MapToSearchModel(IConceptModel model)
 {
     var searchModel = NameableEntityMapper.MapToSearchModel<IConceptModel, ConceptSearchModel>(model);
     // Search Properties
     searchModel.PrimaryImageFileId = model.PrimaryImageFileId;
     searchModel.PrimaryImageFileCustomKey = model.PrimaryImageFile?.CustomKey;
     searchModel.PrimaryImageFileApiDetailUrl = model.PrimaryImageFile?.ApiDetailUrl;
     searchModel.PrimaryImageFileSiteDetailUrl = model.PrimaryImageFile?.SiteDetailUrl;
     searchModel.PrimaryImageFileName = model.PrimaryImageFile?.Name;
     searchModel.PrimaryImageFileShortDescription = model.PrimaryImageFile?.ShortDescription;
     searchModel.PrimaryImageFileDescription = model.PrimaryImageFile?.Description;
     searchModel.FirstIssueAppearanceId = model.FirstIssueAppearanceId;
     searchModel.FirstIssueAppearanceCustomKey = model.FirstIssueAppearance?.CustomKey;
     searchModel.FirstIssueAppearanceApiDetailUrl = model.FirstIssueAppearance?.ApiDetailUrl;
     searchModel.FirstIssueAppearanceSiteDetailUrl = model.FirstIssueAppearance?.SiteDetailUrl;
     searchModel.FirstIssueAppearanceName = model.FirstIssueAppearance?.Name;
     searchModel.FirstIssueAppearanceShortDescription = model.FirstIssueAppearance?.ShortDescription;
     searchModel.FirstIssueAppearanceDescription = model.FirstIssueAppearance?.Description;
     // Return Search Model
     return searchModel;
 }
コード例 #6
0
 public IConceptModel Update(IConceptModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Find existing entity
     // ReSharper disable once PossibleInvalidOperationException
     var existingEntity = ConceptsRepository.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 (ConceptMapper.AreEqual(model, existingEntity))
     {
         return ConceptMapper.MapToModel(existingEntity);
     }
     // Map model to an existing entity
     ConceptMapper.MapToEntity(model, ref existingEntity);
     existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
     // Update it
     ConceptsRepository.Update(ConceptMapper.MapToEntity(model));
     // Try to Save Changes
     ConceptsRepository.SaveChanges();
     // Return the new value
     return Get(existingEntity.Id);
 }