public static void UpdatePersonRoleInFamily(Rock.Client.GroupMember groupMember, int childAdultGroupRoleId, HttpRequest.RequestResult resultHandler) { Rock.Client.GroupMember destGroupMember = new Rock.Client.GroupMember(); // copy over all the other data destGroupMember.GroupMemberStatus = groupMember.GroupMemberStatus; destGroupMember.PersonId = groupMember.PersonId; destGroupMember.Guid = groupMember.Guid; destGroupMember.GroupId = groupMember.GroupId; destGroupMember.GroupRoleId = childAdultGroupRoleId; destGroupMember.Id = groupMember.Id; destGroupMember.IsSystem = groupMember.IsSystem; RockApi.Put_GroupMembers(destGroupMember, Config.Instance.CurrentPersonAliasId, resultHandler); }
static void UpdatePersonImageGroup(Rock.Client.Person person, int modifiedById, HttpRequest.RequestResult resultHandler) { string oDataFilter = string.Format("?$filter=PersonId eq {0} and GroupId eq {1}", person.Id, ApplicationGroup_PhotoRequest_ValueId); RockApi.Get_GroupMembers(oDataFilter, delegate(HttpStatusCode statusCode, string statusDescription, List <Rock.Client.GroupMember> model) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { // if it's null, they are NOT in the group and we should POST. if it's valid, // we can simply update the existing. if (model.Count == 0) { Rock.Client.GroupMember groupMember = new Rock.Client.GroupMember(); groupMember.Guid = Guid.NewGuid( ); groupMember.PersonId = person.Id; groupMember.GroupMemberStatus = GroupMemberStatus_Pending_ValueId; groupMember.GroupId = ApplicationGroup_PhotoRequest_ValueId; groupMember.GroupRoleId = GroupMemberRole_Member_ValueId; RockApi.Post_GroupMembers(groupMember, modifiedById, resultHandler); } else { // otherwise, we'll do a PUT Rock.Client.GroupMember groupMember = new Rock.Client.GroupMember(); // set the status to pending groupMember.GroupMemberStatus = GroupMemberStatus_Pending_ValueId; // and copy over all the other data groupMember.PersonId = model[0].PersonId; groupMember.Guid = model[0].Guid; groupMember.GroupId = model[0].GroupId; groupMember.GroupRoleId = model[0].GroupRoleId; groupMember.Id = model[0].Id; groupMember.IsSystem = model[0].IsSystem; RockApi.Put_GroupMembers(groupMember, modifiedById, resultHandler); } } else { // fail... resultHandler(statusCode, statusDescription); } }); }