Esempio n. 1
0
        /// <summary>
        /// Gets a person field value.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="registrantInfo">The registrant information.</param>
        /// <param name="personFieldType">Type of the person field.</param>
        /// <returns></returns>
        public object GetPersonFieldValue(RegistrationSettings settings, Rock.ViewModel.Blocks.Event.RegistrationEntry.RegistrantInfo registrantInfo, RegistrationPersonFieldType personFieldType)
        {
            if (settings != null && settings.Forms != null)
            {
                var fieldGuid = settings.Forms
                                .SelectMany(t => t.Fields
                                            .Where(f =>
                                                   f.FieldSource == RegistrationFieldSource.PersonField &&
                                                   f.PersonFieldType == personFieldType)
                                            .Select(f => f.Guid))
                                .FirstOrDefault();

                return(registrantInfo.FieldValues.GetValueOrNull(fieldGuid));
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the email.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="registrantInfo">The registrant information.</param>
        /// <returns></returns>
        public string GetEmail(RegistrationSettings settings, Rock.ViewModel.Blocks.Event.RegistrationEntry.RegistrantInfo registrantInfo)
        {
            object value = GetPersonFieldValue(settings, registrantInfo, RegistrationPersonFieldType.Email);

            if (value == null)
            {
                // if Email isn't prompted for in a registration form, and using an existing Person, get the person's email from the database
                if (registrantInfo.PersonGuid.HasValue)
                {
                    return(new PersonService(new RockContext()).GetSelect(registrantInfo.PersonGuid.Value, s => s.Email) ?? string.Empty);
                }
            }
            else
            {
                return(value.ToString());
            }

            return(string.Empty);
        }