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;
 }
Exemplo n.º 2
0
 public VolumeView(IViewController controller, IVolumeModel model)
 {
     this.controller = controller;
     this.model      = model;
     this.model.RegisterObserver(this);
     Console.WriteLine("View: volume init is " + model.Volume);
 }
Exemplo n.º 3
0
 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));
        }
Exemplo n.º 6
0
        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 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();
 }
Exemplo n.º 8
0
        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
         ;
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
 public static IVolume MapToEntity(this IVolumeModel model, int currentDepth = 1)
 {
     return(Mapper.MapToEntity(model, currentDepth));
 }
Exemplo n.º 15
0
 public void Setup()
 {
     mockView  = new MockVolumeSettingsView();
     model     = new VolumeModel();
     presenter = new VolumeSettingsPresenter(mockView, model);
 }
Exemplo n.º 16
0
 public void Teardown()
 {
     mockView  = null;
     model     = null;
     presenter = null;
 }
Exemplo n.º 17
0
 private static void DecreaseVolume(IVolumeModel volumeModel)
 {
     volumeModel.Volume--;
 }
Exemplo n.º 18
0
 private static void IncreaseVolume(IVolumeModel volumeModel)
 {
     volumeModel.Volume++;
 }
Exemplo n.º 19
0
 public static bool AreEqual(this IVolumeModel model, IVolume entity)
 {
     return(Mapper.AreEqual(model, entity));
 }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 23
0
 public void VolumeChanged(IVolumeModel model)
 {
     return((model as VolumeModel).Volume.ToString());
 }
Exemplo n.º 24
0
 public void VolumeChanged(IVolumeModel model)
 {
     // Texte à Afficher
 }
Exemplo n.º 25
0
 public static void MapToEntity(this IVolumeModel model, ref IVolume entity, int currentDepth = 1)
 {
     Mapper.MapToEntity(model, ref entity, currentDepth);
 }