private async void ApplicationBarMenuItem_Click_1(object sender, EventArgs e) { if (addFavePressed == false) { addFavePressed = true; OCDirection direction = OCDirection.newOCDirection(int.Parse(routeNumber.Text), routeName.Text, "", "", 0); direction.FromStopNumber = stopID; direction.FromStopName = fromStopName; direction.DirectionalName = "TO " + this.direction.ToUpper(); int result = await OCTranspoStopsData.addFavouriteStop(direction); if (result > 0) { MessageBox.Show("Your favourite stop was succesfully added."); ApplicationBarIconButton button = (ApplicationBarIconButton)sender; button.IsEnabled = false; favourite = true; } else { MessageBox.Show("There was an error adding your favourite stop, please try again."); addFavePressed = favourite = false; } } }
private async void addFavourite_Click(object sender, RoutedEventArgs e) { var menItem = (MenuItem)sender; OCApiRoute apiRoute = (OCApiRoute)menItem.DataContext; OCDirection direction = OCDirection.newOCDirection(apiRoute.RouteNumber, apiRoute.RouteHeading, apiRoute.Direction, "", 0); direction.FromStopName = stopName.Text; direction.FromStopNumber = int.Parse(stopID.Text); direction.DirectionalName = "TO " + apiRoute.RouteHeading.ToUpper(); int result = await OCTranspoStopsData.addFavouriteStop(direction); if (result > 0) { MessageBox.Show("Your favourite stop was succesfully added."); } else { MessageBox.Show("There was an error adding your favourite stop, please try again."); } }