private void SaveRoute(TripItinerary routeToSave) { var route = new FavoriteRoute { FontIconGlyph = FontIconGlyphs.FilledStar, Id = Guid.NewGuid(), IconFontFace = Constants.SegoeMdl2FontName, IconFontSize = Constants.SymbolFontSize, UserChosenName = $"{routeToSave.StartingPlaceName} → {routeToSave.EndingPlaceName}", }; TripLeg startPlace = routeToSave.ItineraryLegs.First(); TripLeg endPlace = routeToSave.ItineraryLegs.Last(); var places = new List <SimpleFavoritePlace>(); places.Add(new SimpleFavoritePlace { Lat = startPlace.StartCoords.Latitude, Lon = startPlace.StartCoords.Longitude, Name = routeToSave.StartingPlaceName, Type = ModelEnums.PlaceType.FavoritePlace }); places.Add(new SimpleFavoritePlace { Lat = endPlace.EndCoords.Latitude, Lon = endPlace.EndCoords.Longitude, Name = routeToSave.EndingPlaceName, Type = ModelEnums.PlaceType.FavoritePlace }); route.RoutePlaces = places; route.RouteGeometryStrings = routeToSave.RouteGeometryStrings.ToList(); _favoritesService.AddFavorite(route); }
private async void AddNewFavorite() { var dialog = new AddOrEditFavoriteDialog(); await dialog.ShowAsync(); if (dialog.ResultFavorite != null) { _favoritesService.AddFavorite(dialog.ResultFavorite); } }
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; }