public virtual bool AreEqual(ICharacterCreatorModel model, ICharacterCreator entity)
 {
     return EntityMapper.AreEqual(model, entity)
         // CharacterCreator Properties
         // <None>
         // Related Objects
         && model.CharacterId == entity.CharacterId
         && model.CreatorId == entity.CreatorId
         ;
 }
 public virtual void MapToEntity(ICharacterCreatorModel model, ref ICharacterCreator entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     EntityMapper.MapToEntity(model, ref entity);
     // CharacterCreator Properties
     // <None>
     // Related Objects
     entity.CharacterId = model.CharacterId;
     entity.Character = (Character)model.Character?.MapToEntity();
     entity.CreatorId = model.CreatorId;
     entity.Creator = (Person)model.Creator?.MapToEntity();
     // Associated Objects
     // <None>
 }
 public virtual ICharacterCreator MapToEntity(ICharacterCreatorModel model, int currentDepth = 1)
 {
     currentDepth++;
     var entity = EntityMapper.MapToEntity<CharacterCreator, ICharacterCreatorModel>(model);
     // CharacterCreator Properties
     // <None>
     // Related Objects
     entity.CharacterId = model.CharacterId;
     entity.Character = (Character)model.Character?.MapToEntity();
     entity.CreatorId = model.CreatorId;
     entity.Creator = (Person)model.Creator?.MapToEntity();
     // Associated Objects
     // <None>
     // Return Entity
     return entity;
 }
 public ICharacterCreatorModel Create(ICharacterCreatorModel 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(CharacterCreatorMapper.MapToSearchModel(model));
     if (results.Any()) { return results.First(); } // Return the first that matches
     // Map model to a new entity
     var newEntity = CharacterCreatorMapper.MapToEntity(model);
     newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
     newEntity.UpdatedDate = null;
     newEntity.Active = true;
     // Add it
     CharacterCreatorsRepository.Add(newEntity);
     // Try to Save Changes
     CharacterCreatorsRepository.SaveChanges();
     // Return the new value
     return Get(newEntity.Id);
 }
 public ICharacterCreatorModel Update(ICharacterCreatorModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Find existing entity
     // ReSharper disable once PossibleInvalidOperationException
     var existingEntity = CharacterCreatorsRepository.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 (CharacterCreatorMapper.AreEqual(model, existingEntity))
     {
         return CharacterCreatorMapper.MapToModel(existingEntity);
     }
     // Map model to an existing entity
     CharacterCreatorMapper.MapToEntity(model, ref existingEntity);
     existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
     // Update it
     CharacterCreatorsRepository.Update(CharacterCreatorMapper.MapToEntity(model));
     // Try to Save Changes
     CharacterCreatorsRepository.SaveChanges();
     // Return the new value
     return Get(existingEntity.Id);
 }
 public virtual ICharacterCreatorSearchModel MapToSearchModel(ICharacterCreatorModel model)
 {
     var searchModel = EntityMapper.MapToSearchModel<ICharacterCreatorModel, CharacterCreatorSearchModel>(model);
     // Search Properties
     searchModel.CharacterId = model.CharacterId;
     searchModel.CharacterCustomKey = model.Character?.CustomKey;
     searchModel.CharacterApiDetailUrl = model.Character?.ApiDetailUrl;
     searchModel.CharacterSiteDetailUrl = model.Character?.SiteDetailUrl;
     searchModel.CharacterName = model.Character?.Name;
     searchModel.CharacterShortDescription = model.Character?.ShortDescription;
     searchModel.CharacterDescription = model.Character?.Description;
     searchModel.CreatorId = model.CreatorId;
     searchModel.CreatorCustomKey = model.Creator?.CustomKey;
     searchModel.CreatorApiDetailUrl = model.Creator?.ApiDetailUrl;
     searchModel.CreatorSiteDetailUrl = model.Creator?.SiteDetailUrl;
     searchModel.CreatorName = model.Creator?.Name;
     searchModel.CreatorShortDescription = model.Creator?.ShortDescription;
     searchModel.CreatorDescription = model.Creator?.Description;
     // Return Search Model
     return searchModel;
 }