private void LoadPlaceList(GeolocationResult result)
        {
            Func<int> func = delegate {
                PlaceList lPlaceList = new PlaceList ();

                if (result.Position != null)
                {
                    lPlaceList = new PlaceList (
                        Engine.Instance.PlaceLocator.GetNearbyPlaces (
                        (float)result.Position.Latitude, (float)result.Position.Longitude));
                }

                this.BeginInvokeOnMainThread (delegate {
                    if (lPlaceList.Count > 0)
                    {
                        PlaceList = lPlaceList;

                        TableView.ReloadData ();
                        BusyView.Busy = false;
                    }
                    else
                        ShowLocatinError (lPlaceList, result);
                });

                return 0;
            };

            func.BeginInvoke (null, null);
        }
        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);
        }
        public List<Place> GetPlaceListNearLocation(float lat, float lng, int limit)
        {
            List<Place> returnList = new List<Place>();

            SetupAndCall((dbCmd) =>
            {
                SqlExpressionVisitor<Place> evPlace = OrmLiteConfig.DialectProvider.ExpressionVisitor<Place>();
                var placeList = dbCmd.Select(evPlace);

                returnList = new PlaceList(placeList.ToList()).SortByDistance(lat, lng, limit).Places;
            });

            return returnList;
        }
        protected void ShowLocatinError(PlaceList placeList, GeolocationResult result)
        {
            string message;

            if (result.Canceled)
                message = "The location request timed out.";
            else if (result.GeolocationNotAvailable)
                message = "Location services are not available on this device.";
            else if (result.GeolocationDisabled)
                message = "Location services are not enabled for the Evolve application.";
            else
                message = "Did not find any places near your location.";

            BusyView.Busy = false;

            UIAlertView alertNew = new UIAlertView ("Error", message, null, "Close", null);
            alertNew.Show ();
        }
 public PlaceListViewController()
 {
     PlaceList = new PlaceList ();
     GeolocationHelper = new GeolocationHelper ();
 }
 public PlaceListViewDelegate(PlaceListViewController viewController)
 {
     PlaceList = new PlaceList ();
 }
 public PlaceListViewDataSource(PlaceListViewController viewController)
 {
     PlaceList = new PlaceList ();
 }