public IEpisodeTeamModel Update(IEpisodeTeamModel model)
        {
            // Validate model
            BusinessWorkflowBase.ValidateRequiredNullableID(model.Id);
            //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name));
            // Find existing entity
            // ReSharper disable once PossibleInvalidOperationException
            var existingEntity = EpisodeTeamsRepository.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 (EpisodeTeamMapper.AreEqual(model, existingEntity))
            {
                return(EpisodeTeamMapper.MapToModel(existingEntity));
            }
            // Map model to an existing entity
            EpisodeTeamMapper.MapToEntity(model, ref existingEntity);
            existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime;
            // Update it
            EpisodeTeamsRepository.Update(EpisodeTeamMapper.MapToEntity(model));
            // Try to Save Changes
            EpisodeTeamsRepository.SaveChanges();
            // Return the new value
            return(Get(existingEntity.Id));
        }
Exemplo n.º 2
0
        public void Verify_MapToModel_AssignsEpisodeTeamProperties()
        {
            // Arrange
            var mapper = new EpisodeTeamMapper();
            var entity = EpisodeTeamsMockingSetup.DoMockingSetupForEpisodeTeam();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            // <None>
            // Related Objects
            Assert.Equal(entity.Object.EpisodeId, model.EpisodeId);
            Assert.Equal(entity.Object.TeamId, model.TeamId);
            // Associated Objects
            // <None>
        }
 public IEpisodeTeamModel Get(string key)
 {
     BusinessWorkflowBase.ValidateRequiredKey(key);
     return(EpisodeTeamMapper.MapToModel(EpisodeTeamsRepository.Get(key)));
 }
 public IEpisodeTeamModel Get(int id)
 {
     BusinessWorkflowBase.ValidateRequiredID(id);
     return(EpisodeTeamMapper.MapToModel(EpisodeTeamsRepository.Get(id)));
 }
 public void Verify_MapToModel_AssignsEpisodeTeamProperties()
 {
     // Arrange
     var mapper = new EpisodeTeamMapper();
     var entity = EpisodeTeamsMockingSetup.DoMockingSetupForEpisodeTeam();
     // Act
     var model = mapper.MapToModel(entity.Object);
     // Assert
     // <None>
     // Related Objects
     Assert.Equal(entity.Object.EpisodeId, model.EpisodeId);
     Assert.Equal(entity.Object.TeamId, model.TeamId);
     // Associated Objects
     // <None>
 }