Exemplo n.º 1
0
        private List <GroupMember> GetControlData()
        {
            var familyMembers = new List <GroupMember>();

            foreach (NewFamilyMembersRow row in nfmMembers.FamilyMemberRows)
            {
                var groupMember = new GroupMember();
                groupMember.Person      = new Person();
                groupMember.Person.Guid = row.PersonGuid.Value;
                groupMember.Person.RecordStatusReasonValueId = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid()).Id;

                if (row.RoleId.HasValue)
                {
                    groupMember.GroupRoleId = row.RoleId.Value;
                }

                groupMember.Person.TitleValueId = row.TitleValueId;
                groupMember.Person.FirstName    = row.FirstName;
                if (nfmMembers.ShowNickName)
                {
                    groupMember.Person.NickName = row.NickName;
                }

                if (string.IsNullOrWhiteSpace(groupMember.Person.NickName))
                {
                    groupMember.Person.NickName = groupMember.Person.FirstName;
                }

                groupMember.Person.LastName  = row.LastName;
                groupMember.Person.Gender    = row.Gender;
                groupMember.Person.BirthDate = row.BirthDate;
                groupMember.Person.ConnectionStatusValueId = row.ConnectionStatusValueId;
                //groupMember.Person.GraduationDate =

                groupMember.Person.Attributes      = new Dictionary <string, AttributeCache>();
                groupMember.Person.AttributeValues = new Dictionary <string, List <AttributeValue> >();

                foreach (var attributeControl in attributeControls)
                {
                    attributeControl.AttributeList.ForEach(a =>
                    {
                        groupMember.Person.Attributes.Add(a.Key, a);
                        groupMember.Person.AttributeValues.Add(a.Key, new List <AttributeValue>());
                        groupMember.Person.AttributeValues[a.Key].Add(new AttributeValue {
                            AttributeId = a.Id
                        });
                    });

                    NewFamilyAttributesRow attributeRow = attributeControl.AttributesRows.FirstOrDefault(r => r.PersonGuid == row.PersonGuid);
                    if (attributeRow != null)
                    {
                        attributeRow.GetEditValues(groupMember.Person);
                    }
                }

                familyMembers.Add(groupMember);
            }

            return(familyMembers);
        }
Exemplo n.º 2
0
        private List <GroupMember> GetControlData()
        {
            var familyMembers = new List <GroupMember>();

            foreach (NewFamilyMembersRow row in nfmMembers.FamilyMemberRows)
            {
                var groupMember = new GroupMember();
                groupMember.Person      = new Person();
                groupMember.Person.Guid = row.PersonGuid.Value;

                if (row.RoleId.HasValue)
                {
                    groupMember.GroupRoleId = row.RoleId.Value;
                }
                groupMember.Person.TitleValueId = row.TitleValueId;
                groupMember.Person.GivenName    = row.FirstName;
                if (nfmMembers.ShowNickName)
                {
                    groupMember.Person.NickName = row.NickName;
                }
                groupMember.Person.LastName            = row.LastName;
                groupMember.Person.Gender              = row.Gender;
                groupMember.Person.BirthDate           = row.BirthDate;
                groupMember.Person.PersonStatusValueId = row.StatusValueId;
                //groupMember.Person.GraduationDate ==

                groupMember.Person.Attributes      = new Dictionary <string, AttributeCache>();
                groupMember.Person.AttributeValues = new Dictionary <string, List <AttributeValue> >();

                foreach (var attributeControl in attributeControls)
                {
                    attributeControl.AttributeList.ForEach(a =>
                    {
                        groupMember.Person.Attributes.Add(a.Key, a);
                        groupMember.Person.AttributeValues.Add(a.Key, new List <AttributeValue>());
                        groupMember.Person.AttributeValues[a.Key].Add(new AttributeValue {
                            AttributeId = a.Id
                        });
                    });

                    NewFamilyAttributesRow attributeRow = attributeControl.AttributesRows.FirstOrDefault(r => r.PersonGuid == row.PersonGuid);
                    if (attributeRow != null)
                    {
                        attributeRow.GetEditValues(groupMember.Person);
                    }
                }

                familyMembers.Add(groupMember);
            }

            return(familyMembers);
        }
Exemplo n.º 3
0
        private void GetControlData()
        {
            FamilyMembers = new List <GroupMember>();

            int?childMaritalStatusId = null;
            var childMaritalStatus   = DefinedValueCache.Read(GetAttributeValue("ChildMaritalStatus").AsGuid());

            if (childMaritalStatus != null)
            {
                childMaritalStatusId = childMaritalStatus.Id;
            }
            int?adultMaritalStatusId = ddlMaritalStatus.SelectedValueAsInt();

            int recordTypePersonId   = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON.AsGuid()).Id;
            int recordStatusActiveId = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid()).Id;

            foreach (NewFamilyMembersRow row in nfmMembers.FamilyMemberRows)
            {
                var groupMember = new GroupMember();
                groupMember.GroupMemberStatus          = GroupMemberStatus.Active;
                groupMember.Person                     = new Person();
                groupMember.Person.Guid                = row.PersonGuid.Value;
                groupMember.Person.RecordTypeValueId   = recordTypePersonId;
                groupMember.Person.RecordStatusValueId = recordStatusActiveId;

                if (row.RoleId.HasValue)
                {
                    groupMember.GroupRoleId = row.RoleId.Value;

                    if (groupMember.GroupRoleId == _childRoleId)
                    {
                        groupMember.Person.MaritalStatusValueId = childMaritalStatusId;
                    }
                    else
                    {
                        groupMember.Person.MaritalStatusValueId = adultMaritalStatusId;
                    }
                }

                groupMember.Person.TitleValueId  = row.TitleValueId;
                groupMember.Person.FirstName     = row.FirstName;
                groupMember.Person.NickName      = groupMember.Person.FirstName;
                groupMember.Person.LastName      = row.LastName;
                groupMember.Person.SuffixValueId = row.SuffixValueId;
                groupMember.Person.Gender        = row.Gender;

                var birthday = row.BirthDate;
                if (birthday.HasValue)
                {
                    // If setting a future birthdate, subtract a century until birthdate is not greater than today.
                    var today = RockDateTime.Today;
                    while (birthday.Value.CompareTo(today) > 0)
                    {
                        birthday = birthday.Value.AddYears(-100);
                    }
                    groupMember.Person.BirthMonth = birthday.Value.Month;
                    groupMember.Person.BirthDay   = birthday.Value.Day;
                    if (birthday.Value.Year != DateTime.MinValue.Year)
                    {
                        groupMember.Person.BirthYear = birthday.Value.Year;
                    }
                    else
                    {
                        groupMember.Person.BirthYear = null;
                    }
                }
                else
                {
                    groupMember.Person.SetBirthDate(null);
                }

                groupMember.Person.ConnectionStatusValueId = row.ConnectionStatusValueId;
                groupMember.Person.GradeOffset             = row.GradeOffset;

                NewFamilyContactInfoRow contactInfoRow = nfciContactInfo.ContactInfoRows.FirstOrDefault(c => c.PersonGuid == row.PersonGuid);
                if (contactInfoRow != null)
                {
                    string homeNumber = PhoneNumber.CleanNumber(contactInfoRow.HomePhoneNumber);
                    if (_homePhone != null && !string.IsNullOrWhiteSpace(homeNumber))
                    {
                        var homePhoneNumber = new PhoneNumber();
                        homePhoneNumber.NumberTypeValueId = _homePhone.Id;
                        homePhoneNumber.Number            = homeNumber;
                        homePhoneNumber.CountryCode       = PhoneNumber.CleanNumber(contactInfoRow.HomePhoneCountryCode);
                        homePhoneNumber.NumberFormatted   = PhoneNumber.FormattedNumber(homePhoneNumber.CountryCode, homeNumber);
                        groupMember.Person.PhoneNumbers.Add(homePhoneNumber);
                    }

                    string cellNumber = PhoneNumber.CleanNumber(contactInfoRow.CellPhoneNumber);
                    if (_cellPhone != null && !string.IsNullOrWhiteSpace(cellNumber))
                    {
                        var cellPhoneNumber = new PhoneNumber();
                        cellPhoneNumber.NumberTypeValueId  = _cellPhone.Id;
                        cellPhoneNumber.Number             = cellNumber;
                        cellPhoneNumber.CountryCode        = PhoneNumber.CleanNumber(contactInfoRow.CellPhoneCountryCode);
                        cellPhoneNumber.NumberFormatted    = PhoneNumber.FormattedNumber(cellPhoneNumber.CountryCode, cellNumber);
                        cellPhoneNumber.IsMessagingEnabled = contactInfoRow.IsMessagingEnabled;
                        groupMember.Person.PhoneNumbers.Add(cellPhoneNumber);
                    }

                    groupMember.Person.Email = contactInfoRow.Email;
                }
                groupMember.Person.IsEmailActive   = true;
                groupMember.Person.EmailPreference = EmailPreference.EmailAllowed;

                groupMember.Person.LoadAttributes();

                foreach (var attributeControl in attributeControls)
                {
                    NewFamilyAttributesRow attributeRow = attributeControl.AttributesRows.FirstOrDefault(r => r.PersonGuid == row.PersonGuid);
                    if (attributeRow != null)
                    {
                        attributeRow.GetEditValues(groupMember.Person);
                    }
                }

                FamilyMembers.Add(groupMember);
            }
        }
Exemplo n.º 4
0
        private List <GroupMember> GetControlData()
        {
            var familyMembers = new List <GroupMember>();

            int?childMaritalStatusId = null;
            var childMaritalStatus   = DefinedValueCache.Read(GetAttributeValue("ChildMaritalStatus").AsGuid());

            if (childMaritalStatus != null)
            {
                childMaritalStatusId = childMaritalStatus.Id;
            }
            int?adultMaritalStatusId = ddlMaritalStatus.SelectedValueAsInt();

            int recordTypePersonId   = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON.AsGuid()).Id;
            int recordStatusActiveId = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid()).Id;

            foreach (NewFamilyMembersRow row in nfmMembers.FamilyMemberRows)
            {
                var groupMember = new GroupMember();
                groupMember.Person      = new Person();
                groupMember.Person.Guid = row.PersonGuid.Value;
                groupMember.Person.RecordTypeValueId   = recordTypePersonId;
                groupMember.Person.RecordStatusValueId = recordStatusActiveId;

                if (row.RoleId.HasValue)
                {
                    groupMember.GroupRoleId = row.RoleId.Value;

                    if (groupMember.GroupRoleId == _childRoleId)
                    {
                        groupMember.Person.MaritalStatusValueId = childMaritalStatusId;
                    }
                    else
                    {
                        groupMember.Person.MaritalStatusValueId = adultMaritalStatusId;
                    }
                }

                groupMember.Person.TitleValueId            = row.TitleValueId;
                groupMember.Person.FirstName               = row.FirstName;
                groupMember.Person.NickName                = groupMember.Person.FirstName;
                groupMember.Person.LastName                = row.LastName;
                groupMember.Person.SuffixValueId           = row.SuffixValueId;
                groupMember.Person.Gender                  = row.Gender;
                groupMember.Person.BirthDate               = row.BirthDate;
                groupMember.Person.ConnectionStatusValueId = row.ConnectionStatusValueId;
                groupMember.Person.Grade = row.Grade;

                groupMember.Person.EmailPreference = EmailPreference.EmailAllowed;

                groupMember.Person.LoadAttributes();

                foreach (var attributeControl in attributeControls)
                {
                    NewFamilyAttributesRow attributeRow = attributeControl.AttributesRows.FirstOrDefault(r => r.PersonGuid == row.PersonGuid);
                    if (attributeRow != null)
                    {
                        attributeRow.GetEditValues(groupMember.Person);
                    }
                }

                familyMembers.Add(groupMember);
            }

            return(familyMembers);
        }