private void AddRemoveFavoriteButton_Tap(object sender, System.Windows.Input.GestureEventArgs e) { City itemViewModel = new City(); DbEngine EngineWorker = new DbEngine(); itemViewModel = CityList.SelectedItem as City; string Code = itemViewModel.AirportCode; CityList.SelectedItem = null; if (EngineWorker.AddAirportToFavorites(Code) == true) { MessageBox.Show("Το Αεροδρόμιο " + itemViewModel.AirportName + " Προστέθηκε στα Αγαπημένα !"); this.CityList.ItemsSource = GetCity.GetAllCitiesData(); return; } else { MessageBox.Show("Το Aεροδρόμιο " + itemViewModel.AirportName + "Αφαιρέθηκε απο τα Αγαπημένα"); DbEngine.GetFavoriteAirports(); List <string> Favorites = new List <string>(); Favorites = DbEngine.GetFavoriteAirports(); this.CityList.ItemsSource = null; this.CityList.ItemsSource = GetCity.GetFavoriteCities(Favorites); if (this.CityList.Items.Count == 0) { MessageBox.Show("Δεν βρέθηκε καταχώρηση στα αγαπημένα. Επιστροφή..."); CityList.ItemsSource = GetCity.GetAllCitiesData(); } return; } }
public void LoadFavorites() { List <string> Favorites = new List <string>(); Favorites = DbEngine.GetFavoriteAirports(); if (Favorites.Count == 0) { MessageBox.Show("Δεν βρέθηκε καταχώρηση στα αγαπημένα..."); FavoritesListEnabled = false; return; } this.CityList.ItemsSource = GetCity.GetFavoriteCities(Favorites); this.CanvasOption.Visibility = Visibility.Collapsed; FavoritesListEnabled = true; this.MainLabel.Text = "Αγαπημένα"; this.CityList.Visibility = Visibility.Visible; }