private void DeleteFavorite(IFavorite favorite) { if (ListSelectionMode == ListViewSelectionMode.Multiple && _selectedItems != null && _selectedItems.Count > 0) { _favoritesService.RemoveFavorite(_selectedItems.Cast <IFavorite>()); } else { _favoritesService.RemoveFavorite(favorite); } }
private async void AddToFavoriteButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { e.Handled = true; FavoritePlace existingFavorite = (await _favoritesService.GetFavoritesAsync()).FirstOrDefault(x => x == SelectedPlace) as FavoritePlace; if (existingFavorite != null) { _favoritesService.RemoveFavorite(existingFavorite); SelectedPlace = new Place { Confidence = SelectedPlace.Confidence, Lat = SelectedPlace.Lat, Lon = SelectedPlace.Lon, Id = SelectedPlace.Id, Name = SelectedPlace.Name, StringId = SelectedPlace.StringId, Type = PlaceType.Address }; return; } var newFavoritePlace = new FavoritePlace { FontIconGlyph = FontIconGlyphs.FilledStar, Id = Guid.NewGuid(), IconFontFace = ((FontFamily)App.Current.Resources[Constants.SymbolThemeFontResource]).Source, IconFontSize = Constants.SymbolFontSize, Lat = SelectedPlace.Lat, Lon = SelectedPlace.Lon, Name = SelectedPlace.Name, Type = PlaceType.FavoritePlace, UserChosenName = SelectedPlace.Name }; _favoritesService.AddFavorite(newFavoritePlace); SelectedPlace = newFavoritePlace; }