/// <summary> /// Checks if this person or business has been imported and returns the Rock.Person Id /// </summary> /// <param name="individualId">The individual identifier.</param> /// <param name="householdId">The household identifier.</param> /// <returns></returns> private int? GetPersonId( int? individualId = null, int? householdId = null ) { var existingPerson = ImportedPeople.FirstOrDefault( p => p.IndividualId == individualId && p.HouseholdId == householdId ); if ( existingPerson != null ) { return existingPerson.PersonId; } else { int lookupAttributeId = individualId.HasValue ? IndividualAttributeId : HouseholdAttributeId; string lookupValueId = individualId.HasValue ? individualId.ToString() : householdId.ToString(); var lookup = new AttributeValueService().Queryable() .Where( av => av.AttributeId == lookupAttributeId && av.Value == lookupValueId ); var lookupPerson = lookup.FirstOrDefault(); if ( lookupPerson != null ) { ImportedPeople.Add( new ImportedPerson() { PersonId = lookupPerson.EntityId, HouseholdId = householdId, IndividualId = individualId } ); return lookupPerson.EntityId; } } return null; }