Пример #1
0
        public static void GetGroups(int groupTypeId, string street, string city, string state, string zip, int skip, int top, GetGroupsComplete onCompletion)
        {
            MobileAppApi.GroupSearchResult sourceLocation = new MobileAppApi.GroupSearchResult( );

            // first convert the address into a location object
            RockApi.Get_Locations_FromAddress(street, city, state, zip,
                                              delegate(System.Net.HttpStatusCode statusCode, string statusDescription, Rock.Client.Location model)
            {
                // verify the call was successful AND it resulted in a valid location
                if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true &&
                    model != null &&
                    model.Latitude.HasValue == true &&
                    model.Longitude.HasValue == true)
                {
                    // take the source location so we can provide it to the caller
                    sourceLocation.Latitude  = model.Latitude.Value;
                    sourceLocation.Longitude = model.Longitude.Value;

                    MobileAppApi.GetPublicGroupsByLocation(groupTypeId, model.Id, skip, top, delegate(List <MobileAppApi.GroupSearchResult> searchResults)
                    {
                        if (searchResults != null)
                        {
                            onCompletion(sourceLocation, searchResults, true);
                        }
                        else
                        {
                            // pass on empty list on failure
                            onCompletion(sourceLocation, new List <MobileAppApi.GroupSearchResult>(), false);
                        }
                    });
                }
                else
                {
                    onCompletion(sourceLocation, new List <MobileAppApi.GroupSearchResult>( ), Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true ? true : false);
                }
            });
        }