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