in TrafficApp/MainPage.xaml.cs [508:551]
private async Task SaveAsync(LocationData workingCopy)
{
Flyout.GetAttachedFlyout(this.GetTemplateRootForLocation(this.locationInEdit)).Hide();
this.isNewLocationInEdit = false;
this.isExistingLocationBeingRepositioned = false;
bool isAddressNew = workingCopy.Address != this.locationInEdit.Address;
bool areCoordinatesNew = !workingCopy.Position.Equals(this.locationInEdit.Position);
// If just the address OR just the coordinates are new,
// clear the other value so that it can be updated.
if (isAddressNew ^ areCoordinatesNew)
{
if (isAddressNew) workingCopy.Position = new BasicGeoposition();
if (areCoordinatesNew) workingCopy.Address = string.Empty;
}
// If the address, the coordinates, or both have changed, clear the travel
// info and the route so that it doesn't reflect the old position.
if (isAddressNew || areCoordinatesNew)
{
workingCopy.ClearTravelInfo();
this.InputMap.Routes.Clear();
}
this.locationInEdit.Copy(workingCopy);
var currentLocation = await this.GetCurrentLocationAsync();
if (currentLocation != null)
{
if (isAddressNew ^ areCoordinatesNew)
{
await LocationHelper.TryUpdateMissingLocationInfoAsync(this.locationInEdit, currentLocation);
}
}
await LocationDataStore.SaveLocationDataAsync(this.Locations);
if (currentLocation != null)
{
bool isNetworkAvailable = await this.TryUpdateLocationsTravelInfoAsync(this.Locations, currentLocation);
if (isNetworkAvailable) this.InputMap.Routes.Add(new MapRouteView(this.locationInEdit.FastestRoute));
}
}