Exemple #1
0
        private void ApplyGiftCard()
        {
            var alertController = UIAlertController.Create("Enter Gift Card Code", null, UIAlertControllerStyle.Alert);

            alertController.AddTextField(textField => {
                textField.Placeholder = "Gift Card Code";
            });

            alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, action => {
                Console.WriteLine("Cancel action");
            }));

            alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, action => {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                client.ApplyGiftCard(alertController.TextFields [0].Text, checkout, (checkout, error) => {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

                    if (error == null && checkout != null)
                    {
                        Console.WriteLine("Successfully added gift card");
                        this.checkout = checkout;
                        TableView.ReloadData();
                    }
                    else
                    {
                        Console.WriteLine("Error applying gift card: {0}", error);
                    }
                });
            }));

            PresentViewController(alertController, true, null);
        }
 public void AddGiftCard(string code, Action <Checkout, Response> success, Action <RetrofitError> failure)
 {
     BuyClient.ApplyGiftCard(code, Checkout, (data, response) =>
     {
         Checkout = data;
         success(data, response);
     }, failure);
 }