/// <summary> /// Initializes a new instance of the <see cref="GroupPlacementRegistrant" /> class. /// </summary> /// <param name="registrationRegistrant">The registration registrant.</param> /// <param name="person">The person.</param> /// <param name="alreadyPlacedInGroup">if set to <c>true</c> [already placed in group].</param> /// <param name="registrationInstance">The registration instance.</param> /// <param name="options">The options.</param> public GroupPlacementRegistrant(RegistrationRegistrant registrationRegistrant, Person person, bool alreadyPlacedInGroup, RegistrationInstance registrationInstance, GetGroupPlacementRegistrantsParameters options) { this.RegistrationRegistrant = registrationRegistrant; this.Person = person; this.AlreadyPlacedInGroup = alreadyPlacedInGroup; this.RegistrationInstance = registrationInstance; this.Options = options; }
/// <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; DiscountApplies = registrant.DiscountApplies; OnWaitList = registrant.OnWaitList; 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.GetFamily(rockContext); 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)); } } } }
/// <summary> /// Clones this RegistrationRegistrant object to a new RegistrationRegistrant object /// </summary> /// <param name="source">The source.</param> /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param> /// <returns></returns> public static RegistrationRegistrant Clone(this RegistrationRegistrant source, bool deepCopy) { if (deepCopy) { return(source.Clone() as RegistrationRegistrant); } else { var target = new RegistrationRegistrant(); target.CopyPropertiesFrom(source); return(target); } }
/// <summary> /// Copies the properties from another RegistrationRegistrant object to this RegistrationRegistrant object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this RegistrationRegistrant target, RegistrationRegistrant source) { target.Id = source.Id; target.Cost = source.Cost; target.ForeignGuid = source.ForeignGuid; target.ForeignKey = source.ForeignKey; target.GroupMemberId = source.GroupMemberId; target.PersonAliasId = source.PersonAliasId; target.RegistrationId = source.RegistrationId; target.CreatedDateTime = source.CreatedDateTime; target.ModifiedDateTime = source.ModifiedDateTime; target.CreatedByPersonAliasId = source.CreatedByPersonAliasId; target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId; target.Guid = source.Guid; target.ForeignId = source.ForeignId; }
/// <summary> /// Gets the existing value for a specific field for the given registrant. /// </summary> /// <param name="registrant">The registrant.</param> /// <param name="person">The person.</param> /// <param name="family">The family.</param> /// <param name="Field">The field.</param> /// <param name="rockContext">The rock context.</param> /// <returns></returns> public object GetRegistrantValue(RegistrationRegistrant registrant, Person person, Group family, RegistrationTemplateFormField Field, RockContext rockContext) { if (Field.FieldSource == RegistrationFieldSource.PersonField) { if (person != null) { DefinedValueCache dvPhone = null; switch (Field.PersonFieldType) { case RegistrationPersonFieldType.FirstName: return(person.NickName); case RegistrationPersonFieldType.LastName: return(person.LastName); case RegistrationPersonFieldType.Campus: { if (family != null) { return(family.CampusId); } break; } case RegistrationPersonFieldType.Address: { var location = person.GetHomeLocation(rockContext); if (location != null) { return(location.Clone()); } break; } case RegistrationPersonFieldType.Email: return(person.Email); case RegistrationPersonFieldType.Birthdate: return(person.BirthDate); case RegistrationPersonFieldType.Grade: return(person.GraduationYear); case RegistrationPersonFieldType.Gender: return(person.Gender); case RegistrationPersonFieldType.MaritalStatus: return(person.MaritalStatusValueId); case RegistrationPersonFieldType.MobilePhone: { dvPhone = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE); break; } case RegistrationPersonFieldType.HomePhone: { dvPhone = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME); break; } case RegistrationPersonFieldType.WorkPhone: { dvPhone = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK); break; } } if (dvPhone != null) { var phoneNumber = new PersonService(rockContext).GetPhoneNumber(person, dvPhone); if (phoneNumber != null) { return(phoneNumber.Clone()); } } } } else { var attribute = AttributeCache.Read(Field.AttributeId ?? 0); if (attribute != null) { switch (Field.FieldSource) { case RegistrationFieldSource.PersonAttribute: { if (person != null) { if (person.Attributes == null) { person.LoadAttributes(); } return(person.GetAttributeValue(attribute.Key)); } break; } case RegistrationFieldSource.GroupMemberAttribute: { if (registrant != null && registrant.GroupMember != null) { if (registrant.GroupMember.Attributes == null) { registrant.GroupMember.LoadAttributes(); } return(registrant.GroupMember.GetAttributeValue(attribute.Key)); } break; } case RegistrationFieldSource.RegistrationAttribute: { if (registrant != null) { if (registrant.Attributes == null) { registrant.LoadAttributes(); } return(registrant.GetAttributeValue(attribute.Key)); } break; } } } } return(null); }
public GroupPlacementRegistrant(RegistrationRegistrant registrationRegistrant, Person person, bool alreadyPlacedInGroup, string registrationInstanceName, GetGroupPlacementRegistrantsParameters options) : this(registrationRegistrant, person, alreadyPlacedInGroup, registrationRegistrant.Registration.RegistrationInstance, options) { }