public virtual bool AreEqual(ICharacterMovieModel model, ICharacterMovie entity)
 {
     return EntityMapper.AreEqual(model, entity)
         // CharacterMovie Properties
         // <None>
         // Related Objects
         && model.CharacterId == entity.CharacterId
         && model.MovieId == entity.MovieId
         ;
 }
 public virtual void MapToEntity(ICharacterMovieModel model, ref ICharacterMovie entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     EntityMapper.MapToEntity(model, ref entity);
     // CharacterMovie Properties
     // <None>
     // Related Objects
     entity.CharacterId = model.CharacterId;
     entity.Character = (Character)model.Character?.MapToEntity();
     entity.MovieId = model.MovieId;
     entity.Movie = (Movie)model.Movie?.MapToEntity();
     // Associated Objects
     // <None>
 }
 public virtual ICharacterMovie MapToEntity(ICharacterMovieModel model, int currentDepth = 1)
 {
     currentDepth++;
     var entity = EntityMapper.MapToEntity<CharacterMovie, ICharacterMovieModel>(model);
     // CharacterMovie Properties
     // <None>
     // Related Objects
     entity.CharacterId = model.CharacterId;
     entity.Character = (Character)model.Character?.MapToEntity();
     entity.MovieId = model.MovieId;
     entity.Movie = (Movie)model.Movie?.MapToEntity();
     // Associated Objects
     // <None>
     // Return Entity
     return entity;
 }
 public ICharacterMovieModel Create(ICharacterMovieModel 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(CharacterMovieMapper.MapToSearchModel(model));
     if (results.Any()) { return results.First(); } // Return the first that matches
     // Map model to a new entity
     var newEntity = CharacterMovieMapper.MapToEntity(model);
     newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime;
     newEntity.UpdatedDate = null;
     newEntity.Active = true;
     // Add it
     CharacterMoviesRepository.Add(newEntity);
     // Try to Save Changes
     CharacterMoviesRepository.SaveChanges();
     // Return the new value
     return Get(newEntity.Id);
 }
 public ICharacterMovieModel Update(ICharacterMovieModel model)
 {
     // Validate model
     BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
     //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
     // Find existing entity
     // ReSharper disable once PossibleInvalidOperationException
     var existingEntity = CharacterMoviesRepository.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 (CharacterMovieMapper.AreEqual(model, existingEntity))
     {
         return CharacterMovieMapper.MapToModel(existingEntity);
     }
     // Map model to an existing entity
     CharacterMovieMapper.MapToEntity(model, ref existingEntity);
     existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
     // Update it
     CharacterMoviesRepository.Update(CharacterMovieMapper.MapToEntity(model));
     // Try to Save Changes
     CharacterMoviesRepository.SaveChanges();
     // Return the new value
     return Get(existingEntity.Id);
 }
 public virtual ICharacterMovieSearchModel MapToSearchModel(ICharacterMovieModel model)
 {
     var searchModel = EntityMapper.MapToSearchModel<ICharacterMovieModel, CharacterMovieSearchModel>(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.MovieId = model.MovieId;
     searchModel.MovieCustomKey = model.Movie?.CustomKey;
     searchModel.MovieApiDetailUrl = model.Movie?.ApiDetailUrl;
     searchModel.MovieSiteDetailUrl = model.Movie?.SiteDetailUrl;
     searchModel.MovieName = model.Movie?.Name;
     searchModel.MovieShortDescription = model.Movie?.ShortDescription;
     searchModel.MovieDescription = model.Movie?.Description;
     // Return Search Model
     return searchModel;
 }