public virtual IVolume MapToEntity(IVolumeModel model, int currentDepth = 1) { currentDepth++; var entity = NameableEntityMapper.MapToEntity<Volume, IVolumeModel>(model); // Volume Properties entity.Startyear = model.Startyear; // Related Objects entity.PrimaryImageFileId = model.PrimaryImageFileId; entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity(); entity.FirstIssueId = model.FirstIssueId; entity.FirstIssue = (Issue)model.FirstIssue?.MapToEntity(); entity.LastIssueId = model.LastIssueId; entity.LastIssue = (Issue)model.LastIssue?.MapToEntity(); entity.PublisherId = model.PublisherId; entity.Publisher = (Publisher)model.Publisher?.MapToEntity(); // Associated Objects entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).Cast<Issue>().ToList(); entity.VolumeAliases = model.VolumeAliases?.Where(i => i.Active).Select(VolumeAliasMapperExtensions.MapToEntity).Cast<VolumeAlias>().ToList(); entity.VolumeCharacters = model.VolumeCharacters?.Where(i => i.Active).Select(VolumeCharacterMapperExtensions.MapToEntity).Cast<VolumeCharacter>().ToList(); entity.VolumeConcepts = model.VolumeConcepts?.Where(i => i.Active).Select(VolumeConceptMapperExtensions.MapToEntity).Cast<VolumeConcept>().ToList(); entity.VolumeLocations = model.VolumeLocations?.Where(i => i.Active).Select(VolumeLocationMapperExtensions.MapToEntity).Cast<VolumeLocation>().ToList(); entity.VolumeObjects = model.VolumeObjects?.Where(i => i.Active).Select(VolumeObjectMapperExtensions.MapToEntity).Cast<VolumeObject>().ToList(); entity.VolumeTeams = model.VolumeTeams?.Where(i => i.Active).Select(VolumeTeamMapperExtensions.MapToEntity).Cast<VolumeTeam>().ToList(); entity.VolumeWriters = model.VolumeWriters?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToEntity).Cast<VolumeWriter>().ToList(); // Return Entity return entity; }
public VolumeView(IViewController controller, IVolumeModel model) { this.controller = controller; this.model = model; this.model.RegisterObserver(this); Console.WriteLine("View: volume init is " + model.Volume); }
public virtual void MapToEntity(IVolumeModel model, ref IVolume entity, int currentDepth = 1) { currentDepth++; // Assign Base properties NameableEntityMapper.MapToEntity(model, ref entity); // Volume Properties entity.Startyear = model.Startyear; // Related Objects entity.PrimaryImageFileId = model.PrimaryImageFileId; entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity(); entity.FirstIssueId = model.FirstIssueId; entity.FirstIssue = (Issue)model.FirstIssue?.MapToEntity(); entity.LastIssueId = model.LastIssueId; entity.LastIssue = (Issue)model.LastIssue?.MapToEntity(); entity.PublisherId = model.PublisherId; entity.Publisher = (Publisher)model.Publisher?.MapToEntity(); // Associated Objects entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).ToList(); entity.VolumeAliases = model.VolumeAliases?.Where(i => i.Active).Select(VolumeAliasMapperExtensions.MapToEntity).ToList(); entity.VolumeCharacters = model.VolumeCharacters?.Where(i => i.Active).Select(VolumeCharacterMapperExtensions.MapToEntity).ToList(); entity.VolumeConcepts = model.VolumeConcepts?.Where(i => i.Active).Select(VolumeConceptMapperExtensions.MapToEntity).ToList(); entity.VolumeLocations = model.VolumeLocations?.Where(i => i.Active).Select(VolumeLocationMapperExtensions.MapToEntity).ToList(); entity.VolumeObjects = model.VolumeObjects?.Where(i => i.Active).Select(VolumeObjectMapperExtensions.MapToEntity).ToList(); entity.VolumeTeams = model.VolumeTeams?.Where(i => i.Active).Select(VolumeTeamMapperExtensions.MapToEntity).ToList(); entity.VolumeWriters = model.VolumeWriters?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToEntity).ToList(); }
public IVolumeModel Create(IVolumeModel 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(VolumeMapper.MapToSearchModel(model)); if (results.Any()) { return(results.First()); } // Return the first that matches // Map model to a new entity var newEntity = VolumeMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it VolumesRepository.Add(newEntity); // Try to Save Changes VolumesRepository.SaveChanges(); // Return the new value return(Get(newEntity.Id)); }
public IVolumeModel Update(IVolumeModel model) { // Validate model BusinessWorkflowBase.ValidateRequiredNullableID(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Find existing entity // ReSharper disable once PossibleInvalidOperationException var existingEntity = VolumesRepository.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 (VolumeMapper.AreEqual(model, existingEntity)) { return(VolumeMapper.MapToModel(existingEntity)); } // Map model to an existing entity VolumeMapper.MapToEntity(model, ref existingEntity); existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime; // Update it VolumesRepository.Update(VolumeMapper.MapToEntity(model)); // Try to Save Changes VolumesRepository.SaveChanges(); // Return the new value return(Get(existingEntity.Id)); }
public virtual IVolume MapToEntity(IVolumeModel model, int currentDepth = 1) { currentDepth++; var entity = NameableEntityMapper.MapToEntity <Volume, IVolumeModel>(model); // Volume Properties entity.Startyear = model.Startyear; // Related Objects entity.PrimaryImageFileId = model.PrimaryImageFileId; entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity(); entity.FirstIssueId = model.FirstIssueId; entity.FirstIssue = (Issue)model.FirstIssue?.MapToEntity(); entity.LastIssueId = model.LastIssueId; entity.LastIssue = (Issue)model.LastIssue?.MapToEntity(); entity.PublisherId = model.PublisherId; entity.Publisher = (Publisher)model.Publisher?.MapToEntity(); // Associated Objects entity.Issues = model.Issues?.Where(i => i.Active).Select(IssueMapperExtensions.MapToEntity).Cast <Issue>().ToList(); entity.VolumeAliases = model.VolumeAliases?.Where(i => i.Active).Select(VolumeAliasMapperExtensions.MapToEntity).Cast <VolumeAlias>().ToList(); entity.VolumeCharacters = model.VolumeCharacters?.Where(i => i.Active).Select(VolumeCharacterMapperExtensions.MapToEntity).Cast <VolumeCharacter>().ToList(); entity.VolumeConcepts = model.VolumeConcepts?.Where(i => i.Active).Select(VolumeConceptMapperExtensions.MapToEntity).Cast <VolumeConcept>().ToList(); entity.VolumeLocations = model.VolumeLocations?.Where(i => i.Active).Select(VolumeLocationMapperExtensions.MapToEntity).Cast <VolumeLocation>().ToList(); entity.VolumeObjects = model.VolumeObjects?.Where(i => i.Active).Select(VolumeObjectMapperExtensions.MapToEntity).Cast <VolumeObject>().ToList(); entity.VolumeTeams = model.VolumeTeams?.Where(i => i.Active).Select(VolumeTeamMapperExtensions.MapToEntity).Cast <VolumeTeam>().ToList(); entity.VolumeWriters = model.VolumeWriters?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToEntity).Cast <VolumeWriter>().ToList(); // Return Entity return(entity); }
public VolumeSettingsPresenter(IVolumeSettingsView volumeSettingsView, IVolumeModel volumeModel) { volumeSettingsView.OnIncreaseVolumeButtonClicked += () => { IncreaseVolume(volumeModel); }; volumeSettingsView.OnDecreaseVolumeButtonClicked += () => { DecreaseVolume(volumeModel); }; volumeModel.OnVolumeChanged += volume => { OnVolumeChanged(volumeSettingsView, volume); }; }
public virtual bool AreEqual(IVolumeModel model, IVolume entity) { return NameableEntityMapper.AreEqual(model, entity) // Volume Properties && model.Startyear == entity.Startyear // Related Objects && model.PrimaryImageFileId == entity.PrimaryImageFileId && model.FirstIssueId == entity.FirstIssueId && model.LastIssueId == entity.LastIssueId && model.PublisherId == entity.PublisherId ; }
public virtual bool AreEqual(IVolumeModel model, IVolume entity) { return(NameableEntityMapper.AreEqual(model, entity) // Volume Properties && model.Startyear == entity.Startyear // Related Objects && model.PrimaryImageFileId == entity.PrimaryImageFileId && model.FirstIssueId == entity.FirstIssueId && model.LastIssueId == entity.LastIssueId && model.PublisherId == entity.PublisherId ); }
public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var entity = VolumesMockingSetup.DoMockingSetupForVolume(1); var mockVolumesRepository = VolumesMockingSetup.DoMockingSetupForRepository(); mockVolumesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object); var businessWorkflow = new VolumesBusinessWorkflow(mockVolumesRepository.Object, new VolumeMapper()); var model = VolumesMockingSetup.DoMockingSetupForVolumeModel(1); IVolumeModel 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 IVolumeModel Create(IVolumeModel 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(VolumeMapper.MapToSearchModel(model)); if (results.Any()) { return results.First(); } // Return the first that matches // Map model to a new entity var newEntity = VolumeMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it VolumesRepository.Add(newEntity); // Try to Save Changes VolumesRepository.SaveChanges(); // Return the new value return Get(newEntity.Id); }
public virtual IVolumeSearchModel MapToSearchModel(IVolumeModel model) { var searchModel = NameableEntityMapper.MapToSearchModel <IVolumeModel, VolumeSearchModel>(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.FirstIssueId = model.FirstIssueId; searchModel.FirstIssueCustomKey = model.FirstIssue?.CustomKey; searchModel.FirstIssueApiDetailUrl = model.FirstIssue?.ApiDetailUrl; searchModel.FirstIssueSiteDetailUrl = model.FirstIssue?.SiteDetailUrl; searchModel.FirstIssueName = model.FirstIssue?.Name; searchModel.FirstIssueShortDescription = model.FirstIssue?.ShortDescription; searchModel.FirstIssueDescription = model.FirstIssue?.Description; searchModel.LastIssueId = model.LastIssueId; searchModel.LastIssueCustomKey = model.LastIssue?.CustomKey; searchModel.LastIssueApiDetailUrl = model.LastIssue?.ApiDetailUrl; searchModel.LastIssueSiteDetailUrl = model.LastIssue?.SiteDetailUrl; searchModel.LastIssueName = model.LastIssue?.Name; searchModel.LastIssueShortDescription = model.LastIssue?.ShortDescription; searchModel.LastIssueDescription = model.LastIssue?.Description; searchModel.PublisherId = model.PublisherId; searchModel.PublisherCustomKey = model.Publisher?.CustomKey; searchModel.PublisherApiDetailUrl = model.Publisher?.ApiDetailUrl; searchModel.PublisherSiteDetailUrl = model.Publisher?.SiteDetailUrl; searchModel.PublisherName = model.Publisher?.Name; searchModel.PublisherShortDescription = model.Publisher?.ShortDescription; searchModel.PublisherDescription = model.Publisher?.Description; // Return Search Model return(searchModel); }
public static IVolume MapToEntity(this IVolumeModel model, int currentDepth = 1) { return(Mapper.MapToEntity(model, currentDepth)); }
public void Setup() { mockView = new MockVolumeSettingsView(); model = new VolumeModel(); presenter = new VolumeSettingsPresenter(mockView, model); }
public void Teardown() { mockView = null; model = null; presenter = null; }
private static void DecreaseVolume(IVolumeModel volumeModel) { volumeModel.Volume--; }
private static void IncreaseVolume(IVolumeModel volumeModel) { volumeModel.Volume++; }
public static bool AreEqual(this IVolumeModel model, IVolume entity) { return(Mapper.AreEqual(model, entity)); }
public static IVolumeSearchModel MapToSearchModel(this IVolumeModel model) { return(Mapper.MapToSearchModel(model)); }
public IVolumeModel Update(IVolumeModel model) { // Validate model BusinessWorkflowBase.ValidateRequiredNullableID(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Find existing entity // ReSharper disable once PossibleInvalidOperationException var existingEntity = VolumesRepository.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 (VolumeMapper.AreEqual(model, existingEntity)) { return VolumeMapper.MapToModel(existingEntity); } // Map model to an existing entity VolumeMapper.MapToEntity(model, ref existingEntity); existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime; // Update it VolumesRepository.Update(VolumeMapper.MapToEntity(model)); // Try to Save Changes VolumesRepository.SaveChanges(); // Return the new value return Get(existingEntity.Id); }
public virtual IVolumeSearchModel MapToSearchModel(IVolumeModel model) { var searchModel = NameableEntityMapper.MapToSearchModel<IVolumeModel, VolumeSearchModel>(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.FirstIssueId = model.FirstIssueId; searchModel.FirstIssueCustomKey = model.FirstIssue?.CustomKey; searchModel.FirstIssueApiDetailUrl = model.FirstIssue?.ApiDetailUrl; searchModel.FirstIssueSiteDetailUrl = model.FirstIssue?.SiteDetailUrl; searchModel.FirstIssueName = model.FirstIssue?.Name; searchModel.FirstIssueShortDescription = model.FirstIssue?.ShortDescription; searchModel.FirstIssueDescription = model.FirstIssue?.Description; searchModel.LastIssueId = model.LastIssueId; searchModel.LastIssueCustomKey = model.LastIssue?.CustomKey; searchModel.LastIssueApiDetailUrl = model.LastIssue?.ApiDetailUrl; searchModel.LastIssueSiteDetailUrl = model.LastIssue?.SiteDetailUrl; searchModel.LastIssueName = model.LastIssue?.Name; searchModel.LastIssueShortDescription = model.LastIssue?.ShortDescription; searchModel.LastIssueDescription = model.LastIssue?.Description; searchModel.PublisherId = model.PublisherId; searchModel.PublisherCustomKey = model.Publisher?.CustomKey; searchModel.PublisherApiDetailUrl = model.Publisher?.ApiDetailUrl; searchModel.PublisherSiteDetailUrl = model.Publisher?.SiteDetailUrl; searchModel.PublisherName = model.Publisher?.Name; searchModel.PublisherShortDescription = model.Publisher?.ShortDescription; searchModel.PublisherDescription = model.Publisher?.Description; // Return Search Model return searchModel; }
public void VolumeChanged(IVolumeModel model) { return((model as VolumeModel).Volume.ToString()); }
public void VolumeChanged(IVolumeModel model) { // Texte à Afficher }
public static void MapToEntity(this IVolumeModel model, ref IVolume entity, int currentDepth = 1) { Mapper.MapToEntity(model, ref entity, currentDepth); }