public IMovieConceptModel Update(IMovieConceptModel model) { // Validate model BusinessWorkflowBase.ValidateRequiredNullableID(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Find existing entity // ReSharper disable once PossibleInvalidOperationException var existingEntity = MovieConceptsRepository.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 (MovieConceptMapper.AreEqual(model, existingEntity)) { return(MovieConceptMapper.MapToModel(existingEntity)); } // Map model to an existing entity MovieConceptMapper.MapToEntity(model, ref existingEntity); existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime; // Update it MovieConceptsRepository.Update(MovieConceptMapper.MapToEntity(model)); // Try to Save Changes MovieConceptsRepository.SaveChanges(); // Return the new value return(Get(existingEntity.Id)); }
public void Verify_MapToModel_AssignsMovieConceptProperties() { // Arrange var mapper = new MovieConceptMapper(); var entity = MovieConceptsMockingSetup.DoMockingSetupForMovieConcept(); // Act var model = mapper.MapToModel(entity.Object); // Assert // <None> // Related Objects Assert.Equal(entity.Object.MovieId, model.MovieId); Assert.Equal(entity.Object.ConceptId, model.ConceptId); // Associated Objects // <None> }
public IMovieConceptModel Get(string key) { BusinessWorkflowBase.ValidateRequiredKey(key); return(MovieConceptMapper.MapToModel(MovieConceptsRepository.Get(key))); }
public IMovieConceptModel Get(int id) { BusinessWorkflowBase.ValidateRequiredID(id); return(MovieConceptMapper.MapToModel(MovieConceptsRepository.Get(id))); }