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; } } }
public static async Task <int> deleteFavourite(OCDirection direction) { String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite"; SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path); String Query = "DELETE from OCDirection WHERE routeNo=" + direction.RouteNo + " AND FromStopNumber=" + direction.FromStopNumber + ";"; int result = await conn.DeleteAsync(direction); return(result); }
public static OCDirection newOCDirection(int routeNo, String routeLabel, String direction, String procTime, int Id) { OCDirection dir = new OCDirection(); dir.RouteNo = routeNo; dir.RouteLabel = routeLabel; dir.Direction = direction; dir.ProcTime = procTime; dir.Id = Id; return dir; }
public static OCDirection newOCDirection(int routeNo, String routeLabel, String direction, String procTime, int Id) { OCDirection dir = new OCDirection(); dir.RouteNo = routeNo; dir.RouteLabel = routeLabel; dir.Direction = direction; dir.ProcTime = procTime; dir.Id = Id; return(dir); }
// Favourites public static async Task<int> addFavouriteStop(OCDirection direction) { int result = 0; String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite"; SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path); await conn.InsertAsync(direction).ContinueWith((t) => { result = t.Result; }); return result; }
// Favourites public static async Task <int> addFavouriteStop(OCDirection direction) { int result = 0; String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite"; SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path); await conn.InsertAsync(direction).ContinueWith((t) => { result = t.Result; }); return(result); }
private async void deleteFavourite_Click(object sender, RoutedEventArgs e) { var menItem = (MenuItem)sender; OCDirection dir = (OCDirection)menItem.DataContext; int result = await OCTranspoStopsData.deleteFavourite(dir); if (result > 0) { favourites.Remove(dir); } else { MessageBox.Show("There was an issue deleting your favourite."); } }
//Routes List Methods***********************************************************************************************************************************************************// private void routesList_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedItem = ((LongListSelector)sender).SelectedItem; if (selectedItem is OCDirection) { OCDirection stop = (OCDirection)selectedItem; Navigation.NavigateToStopRoute(stop.RouteNo.ToString(), stop.RouteLabel); } else if (selectedItem is OCStop) { OCStop stop = (OCStop)selectedItem; Navigation.NavigateToStopRoute(stop.stop_code.ToString(), stop.stop_name); } ((LongListSelector)sender).SelectedItem = null; }
private static List <OCDirection> makeDirection(XElement routeDir) { List <OCDirection> dirs = new List <OCDirection>(); int routeNo; String routeLabel, direction, procTime; XElement trips; foreach (XElement dir in routeDir.Elements()) { routeNo = int.Parse(dir.Element("RouteNo").Value); routeLabel = dir.Element("RouteLabel").Value; direction = dir.Element("Direction").Value; procTime = dir.Element("RequestProcessingTime").Value; trips = dir.Element("Trips"); dirs.Add(OCDirection.newOCDirection(routeNo, routeLabel, direction, procTime, 0)); } return(dirs); }
private async void refreshFavourites() { if (refreshingFavs == false) { refreshingFavs = true; favourites = await OCTranspoStopsData.getFavourites(); this.routesList.ItemsSource = routes; foreach (OCDirection stop in favourites) { OCDirection stop2 = await stop.fetchTimes(stop.FromStopNumber.ToString()); stop.fourArrivalTimes = stop2.fourArrivalTimes; stop.nextTimes = stop2.nextTimes; } this.favouritesList.ItemsSource = favourites; setFavouriteErrorMessage(false, favourites.Count > 0); refreshingFavs = 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."); } }
public static async Task<int> deleteFavourite(OCDirection direction) { String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite"; SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path); String Query = "DELETE from OCDirection WHERE routeNo=" + direction.RouteNo + " AND FromStopNumber=" + direction.FromStopNumber + ";"; int result = await conn.DeleteAsync(direction); return result; }