public static void GetGroupMembersForPerson(Rock.Client.Person person, GroupMembersForPersonDelegate onResult) { // get all the groupMembers that are this person. string query = string.Format("?$filter=PersonId eq {0}", person.Id); RockApi.Get_GroupMembers(query, delegate(HttpStatusCode statusCode, string statusDescription, List <Rock.Client.GroupMember> groupMemberList) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { onResult(groupMemberList); } }); }
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); } }); }