public IEpisodePersonModel Update(IEpisodePersonModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = EpisodePeopleRepository.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 (EpisodePersonMapper.AreEqual(model, existingEntity))
            {
                return(EpisodePersonMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            EpisodePersonMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            EpisodePeopleRepository.Update(EpisodePersonMapper.MapToEntity(model));
            // Try to Save Changes
            EpisodePeopleRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
Пример #2
0
        public void Verify_MapToModel_AssignsEpisodePersonProperties()
        {
            // Arrange
            var mapper = new EpisodePersonMapper();
            var entity = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePerson();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(entity.Object.EpisodeId, model.EpisodeId);
            Assert.Equal(entity.Object.PersonId, model.PersonId);
            // Associated Objects
            // <None>
        }
 public void Verify_MapToModel_AssignsEpisodePersonProperties()
 {
     // Arrange
     var mapper = new EpisodePersonMapper();
     var entity = EpisodePeopleMockingSetup.DoMockingSetupForEpisodePerson();
     // Act
     var model = mapper.MapToModel(entity.Object);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(entity.Object.EpisodeId, model.EpisodeId);
     Assert.Equal(entity.Object.PersonId, model.PersonId);
     // Associated Objects
     // <None>
 }
 public IEpisodePersonModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(EpisodePersonMapper.MapToModel(EpisodePeopleRepository.Get(key)));
 }
 public IEpisodePersonModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(EpisodePersonMapper.MapToModel(EpisodePeopleRepository.Get(id)));
 }