public override async void ViewDidLoad() { try { await goods.GetNext(); await OrderController.GetInstance(); source = new GoodsSource(goods.List); source.RemoveKeyboard += Source_RemoveKeyboard; GoodsTableView.Source = source; GoodsTableView.ReloadData(); ActivityIndicator.StopAnimating(); this.source.UploadNextItems += async(s, e) => { if (isAsyncUpdateAlowed) { isAsyncUpdateAlowed = false; ActivityIndicator.StartAnimating(); if (await goods.GetNext()) { GoodsTableView.ReloadData(); } ActivityIndicator.StopAnimating(); isAsyncUpdateAlowed = true; } }; this.DrugSearchBar.SearchButtonClicked += async(object sender, EventArgs e) => { ActivityIndicator.StartAnimating(); this.DrugSearchBar.ResignFirstResponder(); List <Goods> search = await goods.Search((sender as UISearchBar).Text); ActivityIndicator.StopAnimating(); GoodsSource sou = new GoodsSource(search); sou.RemoveKeyboard += Source_RemoveKeyboard; GoodsTableView.Source = sou; GoodsTableView.ReloadData(); }; this.DrugSearchBar.TextChanged += (object sender, UISearchBarTextChangedEventArgs e) => { if (String.IsNullOrWhiteSpace(e.SearchText)) { this.DrugSearchBar.ResignFirstResponder(); GoodsTableView.Source = source; GoodsTableView.ReloadData(); } }; } catch { ActivityIndicator.StopAnimating(); PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }
public override async void ViewDidLoad() { try { UIBarButtonItem GoToMapBarItem = new UIBarButtonItem(); GoToMapBarItem.Image = UIImage.FromBundle("Map"); GoToMapBarItem.Clicked += (sender, e) => { PerformSegue("MapSegue", this); }; this.NavigationItem.SetRightBarButtonItem(GoToMapBarItem, true); this.orders = await OrderController.GetInstance(); itemOrder = (from i in orders.ListOfOrders where i.Name == item.Name select i).ToList(); AddButton.TouchUpInside += async(sender, e) => { AddButton.Enabled = false; CountStepper.Enabled = false; this.AddButton.BackgroundColor = UIColor.Red; this.DrugAvailabilityImage.Image = UIImage.FromBundle("Sending"); if (itemOrder.Count == 0) { await orders.AddOrder(new Orders(AppDelegate.UserName, item.Name, false, (int)CountStepper.Value)); orders.ListOfOrders.Add(new OrderItem(item) { Derived = false }); PresentViewController(GetAlertsClass.GetAlertForOrder("Ожидайте заказа"), true, null); } else { await orders.UpdateOrder(new Orders(AppDelegate.UserName, item.Name, false, (int)CountStepper.Value)); itemOrder[0].Derived = false; PresentViewController(GetAlertsClass.GetAlertForOrder("Ожидайте заказа"), true, null); } }; CountStepper.ValueChanged += (object sender, EventArgs e) => { this.DrugCountLabel.Text = (int)((UIStepper)sender).Value + " шт."; this.DrugPriceLabel.Text = ((int)((UIStepper)sender).Value * item.Price) + " BYR"; }; InitInputs(); } catch { PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }
public async override void ViewDidLoad() { try { orders = await OrderController.GetInstance(); OrdersSource source = new OrdersSource(orders.ListOfOrders); OrderTableView.Source = source; OrderTableView.ReloadData(); ActivityIndicator.StopAnimating(); this.RefreshControl = new UIRefreshControl(); this.RefreshControl.ValueChanged += (sender, e) => { this.RefreshControl.BeginRefreshing(); OrderTableView.ReloadData(); this.RefreshControl.EndRefreshing(); }; } catch { ActivityIndicator.StopAnimating(); PresentViewController(GetAlertsClass.GetAlert("Не удалось подключиться к серверу"), true, null); } }