XamarinEvolveIOS.MeetUpViewController.ChangeSortMethod C# (CSharp) Method

ChangeSortMethod() private method

private ChangeSortMethod ( PlaceSortMethod sortMethod ) : void
sortMethod PlaceSortMethod
return void
        private void ChangeSortMethod(PlaceSortMethod sortMethod)
        {
            NavigationItem.SetRightBarButtonItem (null, true);
            BusyView.Busy = true;

            Func<int> func = delegate {
                PlaceList list = new PlaceList ();

                if (sortMethod == PlaceSortMethod.Popularity)
                    list = Engine.Instance.CheckInAccess.GetPopularPlaceList (
                        SystemConstants.MaxPlacesPerRequest);

                else if (sortMethod == PlaceSortMethod.NearConventionCenter)
                {
                    list = Engine.Instance.CheckInAccess.GetPlaceListNearLocation (
                        SystemConstants.DefaultPlace.Latitude,
                        SystemConstants.DefaultPlace.Longitude,
                        SystemConstants.MaxPlacesPerRequest);
                }
                else if (sortMethod == PlaceSortMethod.NearUser)
                {
                    GeolocationResult result =
                        GeolocationHelper.GetLocation ();

                    if (result.Position == null)
                    {
                        this.BeginInvokeOnMainThread (delegate {
                            ShowLocatinError (new XamarinEvolveSSLibrary.PlaceList (), result);
                            NavigationItem.SetRightBarButtonItem (_sortButton, true);
                        });
                        return 0;
                    }

                    list = Engine.Instance.CheckInAccess.GetPlaceListNearLocation (
                        (float)result.Position.Latitude,
                        (float)result.Position.Longitude,
                        SystemConstants.MaxPlacesPerRequest);
                }
                else if (sortMethod == PlaceSortMethod.Recent)
                {
                    list = Engine.Instance.CheckInAccess.GetRecentPlaceList (
                        SystemConstants.MaxPlacesPerRequest);
                }

                this.BeginInvokeOnMainThread (delegate {
                    PlaceList = list;
                    TableView.ReloadData ();
                    SortMethod = sortMethod;
                    BusyView.Busy = false;
                    NavigationItem.SetRightBarButtonItem (_sortButton, true);
                });
                return 0;
            };
            func.BeginInvoke (null, null);
        }