private void AddDiscount() { var alertController = UIAlertController.Create("Enter Discount Code", null, UIAlertControllerStyle.Alert); alertController.AddTextField(textField => { textField.Placeholder = "Discount Code"; }); alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, action => { Console.WriteLine("Cancel action"); })); alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, action => { var discount = new BUYDiscount(alertController.TextFields [0].Text); checkout.Discount = discount; UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; client.UpdateCheckout(checkout, (checkout, error) => { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; if (error == null && checkout != null) { Console.WriteLine("Successfully added discount"); this.checkout = checkout; TableView.ReloadData(); } else { Console.WriteLine("Error applying discount: {0}", error); } }); })); PresentViewController(alertController, true, null); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var shippingRate = shippingRates [indexPath.Row]; checkout.ShippingRate = shippingRate; client.UpdateCheckout(checkout, (checkout, error) => { if (error == null && checkout != null) { var preCheckoutController = new PreCheckoutViewController(client, checkout); preCheckoutController.CurrencyFormatter = currencyFormatter; NavigationController.PushViewController(preCheckoutController, true); } else { Console.WriteLine("Error applying checkout: {0}", error); } }); }