/// <summary> /// Initializes a new instance of the <see cref="RegistrantInfo" /> class. /// </summary> /// <param name="registrationInstance">The registration instance.</param> /// <param name="person">The person.</param> public RegistrantInfo(RegistrationInstance registrationInstance, Person person) : this() { if (person != null) { PersonId = person.Id; using (var rockContext = new RockContext()) { PersonName = person.FullName; var family = person.GetFamilies(rockContext).FirstOrDefault(); if (registrationInstance != null && registrationInstance.RegistrationTemplate != null) { var templateFields = registrationInstance.RegistrationTemplate.Forms .SelectMany(f => f.Fields) .Where(f => !f.IsInternal && f.ShowCurrentValue); foreach (var field in templateFields) { object dbValue = GetRegistrantValue(null, person, family, field, rockContext); if (dbValue != null) { FieldValues.Add(field.Id, new FieldValueObject(field, dbValue)); } } } } } }
/// <summary> /// Initializes a new instance of the <see cref="RegistrantInfo" /> class. /// </summary> /// <param name="registrant">The registrant.</param> /// <param name="rockContext">The rock context.</param> public RegistrantInfo(RegistrationRegistrant registrant, RockContext rockContext) : this() { if (registrant != null) { Id = registrant.Id; Guid = registrant.Guid; GroupMemberId = registrant.GroupMemberId; GroupName = registrant.GroupMember != null && registrant.GroupMember.Group != null ? registrant.GroupMember.Group.Name : string.Empty; RegistrationId = registrant.RegistrationId; Cost = registrant.Cost; Person person = null; Group family = null; if (registrant.PersonAlias != null) { PersonId = registrant.PersonAlias.PersonId; PersonAliasGuid = registrant.PersonAlias.Guid; person = registrant.PersonAlias.Person; if (person != null) { PersonName = person.FullName; family = person.GetFamilies(rockContext).FirstOrDefault(); if (family != null) { FamilyGuid = family.Guid; } } } if (registrant.Registration != null && registrant.Registration.RegistrationInstance != null && registrant.Registration.RegistrationInstance.RegistrationTemplate != null) { var templateFields = registrant.Registration.RegistrationInstance.RegistrationTemplate.Forms .SelectMany(f => f.Fields); foreach (var field in templateFields) { object dbValue = GetRegistrantValue(registrant, person, family, field, rockContext); if (dbValue != null) { FieldValues.Add(field.Id, new FieldValueObject(field, dbValue)); } } foreach (var fee in registrant.Fees) { FeeValues.AddOrIgnore(fee.RegistrationTemplateFeeId, new List <FeeInfo>()); FeeValues[fee.RegistrationTemplateFeeId].Add(new FeeInfo(fee)); } } } }