Rock.Model.PersonAliasService.GetPerson C# (CSharp) Method

GetPerson() public method

Gets the person.
public GetPerson ( System.Guid personAliasGuid ) : Person
personAliasGuid System.Guid The person alias unique identifier.
return Person
        public Person GetPerson(Guid personAliasGuid)
        {
            return Queryable()
                .Where( a => a.Guid.Equals( personAliasGuid ) )
                .Select( a => a.Person )
                .FirstOrDefault();
        }

Same methods

PersonAliasService::GetPerson ( int personAliasId ) : Person

Usage Example

示例#1
0
        /// <summary>
        /// Gets the person entry people that should be used for this action.
        /// </summary>
        /// <param name="rockContext">The rock context to use with database operations.</param>
        /// <param name="currentPersonId">The currently logged in person identifier.</param>
        /// <param name="personEntryPerson">On return will contain the <see cref="Person"/> object to be used for this form.</param>
        /// <param name="personEntrySpouse">On return will contain the <see cref="Person"/> object to be used for this form..</param>
        public void GetPersonEntryPeople(RockContext rockContext, int?currentPersonId, out Person personEntryPerson, out Person personEntrySpouse)
        {
            personEntryPerson = null;
            personEntrySpouse = null;

            var workflowType = ActionTypeCache?.ActivityType?.WorkflowType;

            if (workflowType == null)
            {
                return;
            }

            var personEntrySettings = ActionTypeCache.WorkflowForm?.GetFormPersonEntrySettings(workflowType.FormBuilderTemplate);

            if (personEntrySettings == null)
            {
                return;
            }

            if (personEntrySettings.AutofillCurrentPerson && currentPersonId.HasValue)
            {
                var personService = new PersonService(rockContext);
                personEntryPerson = personService.Get(currentPersonId.Value);
                personEntrySpouse = personEntryPerson.GetSpouse();
            }
            else
            {
                AttributeCache personEntryPersonAttribute = ActionTypeCache.WorkflowForm?.GetPersonEntryPersonAttribute(Activity.Workflow);
                AttributeCache personEntrySpouseAttribute = ActionTypeCache.WorkflowForm?.GetPersonEntrySpouseAttribute(Activity.Workflow);

                // Not using the current person, so initialize with the current value of PersonEntryPersonAttributeGuid (normally this would be null unless then also had a PersonEntry form on previous Activities)
                if (personEntryPersonAttribute != null)
                {
                    var personAliasGuid = GetWorkflowAttributeValue(personEntryPersonAttribute.Guid).AsGuidOrNull();

                    if (personAliasGuid.HasValue)
                    {
                        // the workflow already set a value for the FormEntry person, so use that
                        var personAliasService = new PersonAliasService(rockContext);
                        personEntryPerson = personAliasService.GetPerson(personAliasGuid.Value);
                    }
                }

                // Not using the current person, so initialize with the current value PersonEntrySpouseAttributeGuid (normally this would be null unless then also had a PersonEntry form on previous Activities)
                if (personEntrySpouseAttribute != null)
                {
                    var spousePersonAliasGuid = GetWorkflowAttributeValue(personEntrySpouseAttribute.Guid).AsGuidOrNull();

                    if (spousePersonAliasGuid.HasValue)
                    {
                        // the workflow already set a value for the FormEntry person, so use that
                        var personAliasService = new PersonAliasService(rockContext);
                        personEntrySpouse = personAliasService.GetPerson(spousePersonAliasGuid.Value);
                    }
                }
            }
        }
All Usage Examples Of Rock.Model.PersonAliasService::GetPerson