Ejemplo n.º 1
0
        private async void RunAddress()
        {
            this.SetSearchState(true);
            this.SearchDescription = "Ermittle Position der Adresse ...";
            GlobalCoordinate position = await GeoCoder.GetPositionForAddress(this.AddressStreet + "\n" + this.AddressTown);

            if (position == null)
            {
                this.SetSearchState(false);
                CrossToast.ShowToast("Positionsermittlung fehlgeschlagen");
                return;
            }
            this.SearchDescription = "Suche Tankstellen ...";
            List <PriceInfo> results = await ApiRequests.RequestGasStations(position);

            if (results == null)
            {
                this.SetSearchState(false);
                CrossToast.ShowToast("Suche fehlgeschlagen!");
                return;
            }
            if (results.Count > 0)
            {
                // Add prices to the database
                DbDataProvider.Instance.AddPricesToHistory(results);
                this.ResultsFound?.Invoke(this, results);
                this.SearchDescription = String.Empty; // bug fix for small return delay
            }
            else
            {
                this.SetSearchState(false);
                CrossToast.ShowToast("Es wurden keine Tankstellen gefunden.");
            }
        }
Ejemplo n.º 2
0
        private async void RunGps()
        {
            this.SetSearchState(true);
            this.SearchDescription = "Bestimme aktuelle Position ...";
            GlobalCoordinate position = await GeoLocator.GetCurrentPosition();

            if (position == null)
            {
                this.SetSearchState(false);
                CrossToast.ShowToast("Positionsbestimmung fehlgeschlagen!");
                return;
            }
            this.SearchDescription = "Suche Tankstellen ...";
            List <PriceInfo> results = await ApiRequests.RequestGasStations(new GlobalCoordinate(position.Latitude, position.Longitude));

            if (results == null)
            {
                this.SetSearchState(false);
                CrossToast.ShowToast("Suche fehlgeschlagen!");
                return;
            }
            if (results.Count > 0)
            {
                // Add prices to the database
                DbDataProvider.Instance.AddPricesToHistory(results);
                this.ResultsFound?.Invoke(this, results);
                this.SearchDescription = String.Empty; // bug fix for small return delay
            }
            else
            {
                this.SetSearchState(false);
                CrossToast.ShowToast("Es wurden keine Tankstellen gefunden.");
            }
        }
Ejemplo n.º 3
0
        public async void Load()
        {
            if (this.FavoriteCount > 0)
            {
                this.IsLoadingPrices = true;
                IEnumerable <String>       stationIds = this.Favorites.Select(vm => vm.RepresentedStation.ID);
                Dictionary <String, Price> results    = await ApiRequests.RequestPrices(stationIds);

                if (results != null)
                {
                    foreach (KeyValuePair <String, Price> result in results)
                    {
                        this.Favorites.First(fav => fav.RepresentedStation.ID == result.Key).RepresentedPrice = result.Value;
                    }
                }
                else
                {
                    CrossToast.ShowToast("Preisanfrage fehlgeschlagen");
                }
                this.IsLoadingPrices = false;
            }
        }
Ejemplo n.º 4
0
 private void SaveSettings()
 {
     AppSettings.FuelType = (FuelType)this.FuelTypeIndex;
     CrossToast.ShowToast("Einstellungen gespeichert");
 }
Ejemplo n.º 5
0
 private void AddStationToFavorites()
 {
     bool favoriteKicked = DbDataProvider.Instance.AddFavouriteStation(this.RepresentedStation);
     if (favoriteKicked) CrossToast.ShowToast("Ein Favorit wurde entfernt und durch diese Tankstelle ersetzt.");
     this.IsFavorite = DbDataProvider.Instance.IsFavorite(this.RepresentedStation.ID);
 }