예제 #1
0
        public async Task SaveAsync(T item)
        {
            await LoadIfNotCached();

            _loadingService.StartLoading("Odosielam položku");
            try
            {
                if (item.Id == null)
                {
                    await _table.InsertAsync(item);

                    _cachedItems.Add(item);
                }
                else
                {
                    await _table.UpdateAsync(item);

                    _cachedItems.RemoveAll(i => i.Id == item.Id);
                    _cachedItems.Add(item);
                }
            }
            catch (Exception e)
            {
                _dialogService.ShowDialog("Chyba spojenia", e.Message);
            }
            _loadingService.StopLoading();
        }
예제 #2
0
        public async Task <Placemark> GetLocation()
        {
            Placemark ret = null;

            _loadingService.StartLoading("Načítavam pozíciu");

            try
            {
                var location = await Geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Low));

                if (location != null)
                {
                    var placemarks = await Geocoding.GetPlacemarksAsync(location.Latitude, location.Longitude);

                    if (placemarks != null)
                    {
                        ret = placemarks.FirstOrDefault();
                    }
                }
            }
            catch (Exception e)
            {
                _dialogService.ShowDialog("Lokalizácia neúspešná", e.Message);
            }

            _loadingService.StopLoading();
            return(ret);
        }