Example #1
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                var user = new User();
                _storeService = new StoreService();
                var userLocation = await user.CurrentLocation();

                var parameters = "latitude=" + userLocation.Latitude + "&longtitude=" + userLocation.Longitude + "&live=true";
                var asnycList  = await _storeService.GetList(parameters);

                foreach (var item in asnycList)
                {
                    if (item.Distance > 0)
                    {
                        item.DistanceString = LocationMonanager.MetersToString(item.Distance);
                    }
                    stores.Add(item);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #2
0
        public async Task <Xamarin.Essentials.Location> CurrentLocation()
        {
            var currentLocation = new Xamarin.Essentials.Location();

            try
            {
                var locationManager = new LocationMonanager();
                currentLocation = await locationManager.GetLocationCache();

                return(currentLocation);
            }
            catch
            {
                throw;
            }
        }