Example #1
0
        /// <summary>
        /// Second helper method for GetPersonForEdit. This basically takes a list of Rock.Client.Group and gets the Rock.Client.Family for each one.
        /// </summary>
        static void GroupsToFamilies(List <Rock.Client.Group> groupFamilies, Rock.Client.Person refreshedPerson, PersonEditResponseDelegate response)
        {
            List <Rock.Client.Family> families = new List <Rock.Client.Family>( );
            int groupsResolved = 0;

            // now get all the FAMILY objects for these family GROUPS
            foreach (Rock.Client.Group group in groupFamilies)
            {
                RockApi.Get_Groups_GetFamily(group.Id,
                                             delegate(HttpStatusCode statusCode, string statusDescription, Rock.Client.Family model)
                {
                    if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode))
                    {
                        // serialize the responses on the UI thread so we can be sure it's all thread safe
                        Rock.Mobile.Threading.Util.PerformOnUIThread(
                            delegate
                        {
                            families.Add(model);

                            groupsResolved++;
                            if (groupsResolved == groupFamilies.Count)
                            {
                                response(refreshedPerson, families);
                            }
                        });
                    }
                    else
                    {
                        response(null, null);
                    }
                });
            }
        }