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); }
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); }