public virtual void MapToEntity(IImageFileModel model, ref IImageFile entity, int currentDepth = 1) { currentDepth++; // Assign Base properties NameableEntityMapper.MapToEntity(model, ref entity); // ImageFile Properties // <None> // Related Objects // <None> // Associated Objects entity.Characters = model.Characters?.Where(i => i.Active).Select(CharacterMapperExtensions.MapToEntity).ToList(); entity.Chats = model.Chats?.Where(i => i.Active).Select(ChatMapperExtensions.MapToEntity).ToList(); entity.Concepts = model.Concepts?.Where(i => i.Active).Select(ConceptMapperExtensions.MapToEntity).ToList(); entity.Episodes = model.Episodes?.Where(i => i.Active).Select(EpisodeMapperExtensions.MapToEntity).ToList(); entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).ToList(); entity.Locations = model.Locations?.Where(i => i.Active).Select(LocationMapperExtensions.MapToEntity).ToList(); entity.Movies = model.Movies?.Where(i => i.Active).Select(MovieMapperExtensions.MapToEntity).ToList(); entity.Objects = model.Objects?.Where(i => i.Active).Select(ObjectMapperExtensions.MapToEntity).ToList(); entity.People = model.People?.Where(i => i.Active).Select(PersonMapperExtensions.MapToEntity).ToList(); entity.Promos = model.Promos?.Where(i => i.Active).Select(PromoMapperExtensions.MapToEntity).ToList(); entity.Publishers = model.Publishers?.Where(i => i.Active).Select(PublisherMapperExtensions.MapToEntity).ToList(); entity.StoryArcs = model.StoryArcs?.Where(i => i.Active).Select(StoryArcMapperExtensions.MapToEntity).ToList(); entity.Teams = model.Teams?.Where(i => i.Active).Select(TeamMapperExtensions.MapToEntity).ToList(); entity.Videos = model.Videos?.Where(i => i.Active).Select(VideoMapperExtensions.MapToEntity).ToList(); entity.Volumes = model.Volumes?.Where(i => i.Active).Select(VolumeMapperExtensions.MapToEntity).ToList(); }
public IImageFileModel Create(IImageFileModel 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(ImageFileMapper.MapToSearchModel(model)); if (results.Any()) { return(results.First()); } // Return the first that matches // Map model to a new entity var newEntity = ImageFileMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it ImageFilesRepository.Add(newEntity); // Try to Save Changes ImageFilesRepository.SaveChanges(); // Return the new value return(Get(newEntity.Id)); }
public virtual IImageFile MapToEntity(IImageFileModel model, int currentDepth = 1) { currentDepth++; var entity = NameableEntityMapper.MapToEntity<ImageFile, IImageFileModel>(model); // ImageFile Properties // <None> // Related Objects // <None> // Associated Objects entity.Characters = model.Characters?.Where(i => i.Active).Select(CharacterMapperExtensions.MapToEntity).Cast<Character>().ToList(); entity.Chats = model.Chats?.Where(i => i.Active).Select(ChatMapperExtensions.MapToEntity).Cast<Chat>().ToList(); entity.Concepts = model.Concepts?.Where(i => i.Active).Select(ConceptMapperExtensions.MapToEntity).Cast<Concept>().ToList(); entity.Episodes = model.Episodes?.Where(i => i.Active).Select(EpisodeMapperExtensions.MapToEntity).Cast<Episode>().ToList(); entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).Cast<Issue>().ToList(); entity.Locations = model.Locations?.Where(i => i.Active).Select(LocationMapperExtensions.MapToEntity).Cast<Location>().ToList(); entity.Movies = model.Movies?.Where(i => i.Active).Select(MovieMapperExtensions.MapToEntity).Cast<Movie>().ToList(); entity.Objects = model.Objects?.Where(i => i.Active).Select(ObjectMapperExtensions.MapToEntity).Cast<Object>().ToList(); entity.People = model.People?.Where(i => i.Active).Select(PersonMapperExtensions.MapToEntity).Cast<Person>().ToList(); entity.Promos = model.Promos?.Where(i => i.Active).Select(PromoMapperExtensions.MapToEntity).Cast<Promo>().ToList(); entity.Publishers = model.Publishers?.Where(i => i.Active).Select(PublisherMapperExtensions.MapToEntity).Cast<Publisher>().ToList(); entity.StoryArcs = model.StoryArcs?.Where(i => i.Active).Select(StoryArcMapperExtensions.MapToEntity).Cast<StoryArc>().ToList(); entity.Teams = model.Teams?.Where(i => i.Active).Select(TeamMapperExtensions.MapToEntity).Cast<Team>().ToList(); entity.Videos = model.Videos?.Where(i => i.Active).Select(VideoMapperExtensions.MapToEntity).Cast<Video>().ToList(); entity.Volumes = model.Volumes?.Where(i => i.Active).Select(VolumeMapperExtensions.MapToEntity).Cast<Volume>().ToList(); // Return Entity return entity; }
public virtual IImageFile MapToEntity(IImageFileModel model, int currentDepth = 1) { currentDepth++; var entity = NameableEntityMapper.MapToEntity <ImageFile, IImageFileModel>(model); // ImageFile Properties // <None> // Related Objects // <None> // Associated Objects entity.Characters = model.Characters?.Where(i => i.Active).Select(CharacterMapperExtensions.MapToEntity).Cast <Character>().ToList(); entity.Chats = model.Chats?.Where(i => i.Active).Select(ChatMapperExtensions.MapToEntity).Cast <Chat>().ToList(); entity.Concepts = model.Concepts?.Where(i => i.Active).Select(ConceptMapperExtensions.MapToEntity).Cast <Concept>().ToList(); entity.Episodes = model.Episodes?.Where(i => i.Active).Select(EpisodeMapperExtensions.MapToEntity).Cast <Episode>().ToList(); entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).Cast <Issue>().ToList(); entity.Locations = model.Locations?.Where(i => i.Active).Select(LocationMapperExtensions.MapToEntity).Cast <Location>().ToList(); entity.Movies = model.Movies?.Where(i => i.Active).Select(MovieMapperExtensions.MapToEntity).Cast <Movie>().ToList(); entity.Objects = model.Objects?.Where(i => i.Active).Select(ObjectMapperExtensions.MapToEntity).Cast <Object>().ToList(); entity.People = model.People?.Where(i => i.Active).Select(PersonMapperExtensions.MapToEntity).Cast <Person>().ToList(); entity.Promos = model.Promos?.Where(i => i.Active).Select(PromoMapperExtensions.MapToEntity).Cast <Promo>().ToList(); entity.Publishers = model.Publishers?.Where(i => i.Active).Select(PublisherMapperExtensions.MapToEntity).Cast <Publisher>().ToList(); entity.StoryArcs = model.StoryArcs?.Where(i => i.Active).Select(StoryArcMapperExtensions.MapToEntity).Cast <StoryArc>().ToList(); entity.Teams = model.Teams?.Where(i => i.Active).Select(TeamMapperExtensions.MapToEntity).Cast <Team>().ToList(); entity.Videos = model.Videos?.Where(i => i.Active).Select(VideoMapperExtensions.MapToEntity).Cast <Video>().ToList(); entity.Volumes = model.Volumes?.Where(i => i.Active).Select(VolumeMapperExtensions.MapToEntity).Cast <Volume>().ToList(); // Return Entity return(entity); }
public virtual void MapToEntity(IImageFileModel model, ref IImageFile entity, int currentDepth = 1) { currentDepth++; // Assign Base properties NameableEntityMapper.MapToEntity(model, ref entity); // ImageFile Properties // <None> // Related Objects // <None> // Associated Objects entity.Characters = model.Characters?.Where(i => i.Active).Select(CharacterMapperExtensions.MapToEntity).ToList(); entity.Chats = model.Chats?.Where(i => i.Active).Select(ChatMapperExtensions.MapToEntity).ToList(); entity.Concepts = model.Concepts?.Where(i => i.Active).Select(ConceptMapperExtensions.MapToEntity).ToList(); entity.Episodes = model.Episodes?.Where(i => i.Active).Select(EpisodeMapperExtensions.MapToEntity).ToList(); entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).ToList(); entity.Locations = model.Locations?.Where(i => i.Active).Select(LocationMapperExtensions.MapToEntity).ToList(); entity.Movies = model.Movies?.Where(i => i.Active).Select(MovieMapperExtensions.MapToEntity).ToList(); entity.Objects = model.Objects?.Where(i => i.Active).Select(ObjectMapperExtensions.MapToEntity).ToList(); entity.People = model.People?.Where(i => i.Active).Select(PersonMapperExtensions.MapToEntity).ToList(); entity.Promos = model.Promos?.Where(i => i.Active).Select(PromoMapperExtensions.MapToEntity).ToList(); entity.Publishers = model.Publishers?.Where(i => i.Active).Select(PublisherMapperExtensions.MapToEntity).ToList(); entity.StoryArcs = model.StoryArcs?.Where(i => i.Active).Select(StoryArcMapperExtensions.MapToEntity).ToList(); entity.Teams = model.Teams?.Where(i => i.Active).Select(TeamMapperExtensions.MapToEntity).ToList(); entity.Videos = model.Videos?.Where(i => i.Active).Select(VideoMapperExtensions.MapToEntity).ToList(); entity.Volumes = model.Volumes?.Where(i => i.Active).Select(VolumeMapperExtensions.MapToEntity).ToList(); }
public IImageFileModel Update(IImageFileModel model) { // Validate model BusinessWorkflowBase.ValidateRequiredNullableID(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Find existing entity // ReSharper disable once PossibleInvalidOperationException var existingEntity = ImageFilesRepository.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 (ImageFileMapper.AreEqual(model, existingEntity)) { return(ImageFileMapper.MapToModel(existingEntity)); } // Map model to an existing entity ImageFileMapper.MapToEntity(model, ref existingEntity); existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime; // Update it ImageFilesRepository.Update(ImageFileMapper.MapToEntity(model)); // Try to Save Changes ImageFilesRepository.SaveChanges(); // Return the new value return(Get(existingEntity.Id)); }
public virtual IImageFileSearchModel MapToSearchModel(IImageFileModel model) { var searchModel = NameableEntityMapper.MapToSearchModel <IImageFileModel, ImageFileSearchModel>(model); // Search Properties // Return Search Model return(searchModel); }
public virtual bool AreEqual(IImageFileModel model, IImageFile entity) { return NameableEntityMapper.AreEqual(model, entity) // ImageFile Properties // <None> // Related Objects // <None> ; }
public virtual bool AreEqual(IImageFileModel model, IImageFile entity) { return(NameableEntityMapper.AreEqual(model, entity) // ImageFile Properties // <None> // Related Objects // <None> ); }
public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var entity = ImageFilesMockingSetup.DoMockingSetupForImageFile(1); var mockImageFilesRepository = ImageFilesMockingSetup.DoMockingSetupForRepository(); mockImageFilesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object); var businessWorkflow = new ImageFilesBusinessWorkflow(mockImageFilesRepository.Object, new ImageFileMapper()); var model = ImageFilesMockingSetup.DoMockingSetupForImageFileModel(1); IImageFileModel result = null; // Act try { result = businessWorkflow.Update(model.Object); } catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ } // Assert Assert.NotNull(result); Assert.Equal("/TEST/KING-STEPHEN", result.ApiDetailUrl); Assert.Null(result.UpdatedDate); }
public IImageFileModel Create(IImageFileModel 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(ImageFileMapper.MapToSearchModel(model)); if (results.Any()) { return results.First(); } // Return the first that matches // Map model to a new entity var newEntity = ImageFileMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it ImageFilesRepository.Add(newEntity); // Try to Save Changes ImageFilesRepository.SaveChanges(); // Return the new value return Get(newEntity.Id); }
public static bool AreEqual(this IImageFileModel model, IImageFile entity) { return(Mapper.AreEqual(model, entity)); }
public virtual IImageFileSearchModel MapToSearchModel(IImageFileModel model) { var searchModel = NameableEntityMapper.MapToSearchModel<IImageFileModel, ImageFileSearchModel>(model); // Search Properties // Return Search Model return searchModel; }
public IImageFileModel Update(IImageFileModel model) { // Validate model BusinessWorkflowBase.ValidateRequiredNullableID(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Find existing entity // ReSharper disable once PossibleInvalidOperationException var existingEntity = ImageFilesRepository.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 (ImageFileMapper.AreEqual(model, existingEntity)) { return ImageFileMapper.MapToModel(existingEntity); } // Map model to an existing entity ImageFileMapper.MapToEntity(model, ref existingEntity); existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime; // Update it ImageFilesRepository.Update(ImageFileMapper.MapToEntity(model)); // Try to Save Changes ImageFilesRepository.SaveChanges(); // Return the new value return Get(existingEntity.Id); }
public static IImageFileSearchModel MapToSearchModel(this IImageFileModel model) { return(Mapper.MapToSearchModel(model)); }
public static void MapToEntity(this IImageFileModel model, ref IImageFile entity, int currentDepth = 1) { Mapper.MapToEntity(model, ref entity, currentDepth); }
public static IImageFile MapToEntity(this IImageFileModel model, int currentDepth = 1) { return(Mapper.MapToEntity(model, currentDepth)); }