コード例 #1
0
ファイル: SearchStartVM.cs プロジェクト: lukoerfer/fuelradar
        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.");
            }
        }
コード例 #2
0
ファイル: SearchStartVM.cs プロジェクト: lukoerfer/fuelradar
        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.");
            }
        }
コード例 #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;
            }
        }
コード例 #4
0
ファイル: SettingsVM.cs プロジェクト: lukoerfer/fuelradar
 private void SaveSettings()
 {
     AppSettings.FuelType = (FuelType)this.FuelTypeIndex;
     CrossToast.ShowToast("Einstellungen gespeichert");
 }
コード例 #5
0
ファイル: PriceInfoVM.cs プロジェクト: lukoerfer/fuelradar
 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);
 }