private void AddGroupMember() { int defaultRoleId = _groupType.DefaultGroupRoleId ?? _groupType.Roles.Select(r => r.Id).FirstOrDefault(); 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; var ConnectionStatusValue = DefinedValueCache.Read(GetAttributeValue("DefaultConnectionStatus").AsGuid()); var person = new Person(); person.Guid = Guid.NewGuid(); person.RecordTypeValueId = recordTypePersonId; person.RecordStatusValueId = recordStatusActiveId; person.Gender = Gender.Unknown; person.ConnectionStatusValueId = (ConnectionStatusValue != null) ? ConnectionStatusValue.Id : (int?)null; var groupMember = new GroupMember(); groupMember.GroupMemberStatus = GroupMemberStatus.Active; groupMember.GroupRoleId = defaultRoleId; groupMember.Person = person; if (GetAttributeValue("EnableCommonLastName").AsBoolean()) { if (GroupMembers.Count > 0) { person.LastName = GroupMembers.FirstOrDefault().Person.LastName; } } GroupMembers.Add(groupMember); }
/// <summary> /// Handles the DeleteClick event of the groupMemberRow control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> void groupMemberRow_DeleteClick(object sender, EventArgs e) { NewGroupMembersRow row = sender as NewGroupMembersRow; var groupMember = GroupMembers.FirstOrDefault(m => m.Person.Guid.Equals(row.PersonGuid)); if (groupMember != null) { GroupMembers.Remove(groupMember); } CreateControls(true); }