Ejemplo n.º 1
0
 public Task<BaseAudioticaResponse> SubscribeAsync(
     SubscriptionType plan, 
     SubcriptionTimeFrame timeFrame, 
     AudioticaStripeCard card, 
     string coupon = null)
 {
     throw new NotImplementedException();
 }
        private async void ButtonClick(object sender, RoutedEventArgs e)
        {
            var card = new AudioticaStripeCard
            {
                Name = this.CardNameBox.Text, 
                Number = this.CardNumBox.Text, 
                Cvc = this.CardSecurityCode.Text
            };

            var nameEmpty = string.IsNullOrEmpty(card.Name);
            var numberEmpty = string.IsNullOrEmpty(card.Number);
            var cvcEmpty = string.IsNullOrEmpty(card.Cvc);
            var expEmpty = this.ExpMonthBox.SelectedIndex == -1 || this.ExpYearBox.SelectedIndex == -1;

            if (nameEmpty && numberEmpty && cvcEmpty && expEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter all your card information.");
            }
            else if (nameEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the name on the card.");
            }
            else if (numberEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's number.");
            }
            else if (cvcEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's security code.");
            }
            else if (expEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's expiration date.");
            }
            else
            {
                card.ExpMonth = int.Parse(this.ExpMonthBox.SelectedItem as string);
                card.ExpYear = int.Parse(this.ExpYearBox.SelectedItem as string);

                var term = SubcriptionTimeFrame.Month;

                switch (this.PlanBox.SelectedIndex)
                {
                    case 1:
                        term = SubcriptionTimeFrame.Biyear;
                        break;
                    case 2:
                        term = SubcriptionTimeFrame.Year;
                        break;
                }

                UiBlockerUtility.Block("Subscribing...");
                var result =
                    await
                    App.Locator.AudioticaService.SubscribeAsync(
                        SubscriptionType.Silver, 
                        term, 
                        card, 
                        this.CouponCode.Text.Trim());
                UiBlockerUtility.Unblock();

                if (result.Success)
                {
                    CurtainPrompt.Show("Welcome to the Cloud Club!");
                    App.Navigator.GoBack();
                }
                else
                {
                    CurtainPrompt.ShowError(result.Message);
                }
            }
        }