protected override async void OnAppearing() { base.OnAppearing(); await orderLogic.Init(); await statusLogic.Init(); await cartLogic.Init(); var orderList = (from orders in orderLogic.MyOrders join os in statusLogic.Statuses on orders.OrderStatusId equals os.Id orderby orders.Id descending select new OrdersPageModel { Id = orders.Id, OrderDate = orders.OrderDate, Status = os.Name, TotalCost = orders.TotalCost, StatusId = os.Id }).ToList(); General.AllOrders = orderLogic.AllOrders; General.AllCart = cartLogic.AllCart; ordersListView.ItemsSource = orderList; //ordersListView.ItemSelected += OrdersListView_ItemSelected; ordersListView.Refreshing += OrdersListView_Refreshing; }
public async void Scanner() { if (details.StatusName != "On it's way!") { await DisplayAlert("Order #" + details.Id, "You cannot confirm order delivery for this order.", "OK"); await Navigation.PopAsync(); } await deliveryLogic.Init(); await driverLogic.Init(); await orderLogic.Init(); await statusLogic.Init(); var delivery = deliveryLogic.GetDelivery(details, deliveryLogic.AllDeliveries); var driver = driverLogic.GetDriver(delivery, driverLogic.AllDrivers); var order = orderLogic.AllOrders.Where(o => o.Id == details.Id).FirstOrDefault(); var completedStatus = statusLogic.Statuses.Where(s => s.Name == "Completed").FirstOrDefault(); var ScannerPage = new ZXingScannerPage(); ScannerPage.OnScanResult += (result) => { ScannerPage.IsScanning = false; Device.BeginInvokeOnMainThread(async() => { // Logic to confirm order delivery in here if (result.Text == delivery.QRCodeTextConfirmation) { await Navigation.PopAsync(); await ConfirmAsync(delivery, driver, order, completedStatus); await DisplayAlert("Order #" + details.Id, "You successfully confirmed delivery!", "OK"); } else { await Navigation.PopAsync(); await DisplayAlert("Order #" + details.Id, "Not the right QR to confirm delivery.", "OK"); } }); }; await Navigation.PushAsync(ScannerPage); }