Beispiel #1
0
        private async void ProceedExistingClicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(DropdownAddCard.Label) || DropdownAddCard.Label == "Select Existing Card")
            {
                await DisplayAlert("Prompt", "Please select a card", "OK");
            }
            else if (string.IsNullOrEmpty(DropdownCardAmount.Label) || DropdownCardAmount.Label == "Select...")
            {
                await DisplayAlert("Prompt", "Please choose an amount to Top up", "OK");
            }
            else
            {
                var page          = new TopupPage();
                var amount        = DropdownCardAmount.Label + "00";
                var retrievedCard = _listCard.Single(p => p.Name == DropdownAddCard.Label);
                StartBusyIndicator();
                //MessagingCenter.Send<Card>(card, "SaveCard");
                var success = await DependencyService.Get <ITopupPaymentService>().ProcessExistingCard(Int32.Parse(amount.Replace("£", "")), _credential.User.Email, retrievedCard);

                if (success.Keys.First())
                {
                    StopBusyIndicator();
                    await DisplayAlert("Success", "Topup Success", "OK");

                    Navigation.InsertPageBefore(page, this);
                    await Navigation.PopAsync().ConfigureAwait(false);
                }
                else
                {
                    StopBusyIndicator();
                    await DisplayAlert("Error", success.Values.First(), "OK");
                }
            }
        }
Beispiel #2
0
        private async void ProceedClicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(NameInput.Text) || string.IsNullOrEmpty(ExpiryMonthInput.Text) || string.IsNullOrEmpty(ExpiryYearInput.Text) ||
                string.IsNullOrEmpty(CVCInput.Text) || string.IsNullOrEmpty(Dropdown.Label) || Dropdown.Label == "Select...")
            {
                await DisplayAlert("Prompt", "Please fill up all the entry", "OK");
            }
            else
            {
                var card = new Card()
                {
                    Name        = NameInput.Text,
                    Number      = NumberInput.Text,
                    ExpiryMonth = int.Parse(ExpiryMonthInput.Text),
                    ExpiryYear  = int.Parse(ExpiryYearInput.Text),
                    CVC         = CVCInput.Text,
                };
                var last4              = NumberInput.Text.Substring(NumberInput.Text.Length - 4);
                var page               = new TopupPage();
                var amount             = Dropdown.Label + "00";
                var isCardAlreadyExist = _listCard.Any(p => p.Last4 == last4 && p.Name == NameInput.Text);
                if (isCardAlreadyExist)
                {
                    await DisplayAlert("Error", "Card Already Exists", "OK");
                }
                else
                {
                    StartBusyIndicator();
                    //MessagingCenter.Send<Card>(card, "SaveCard");
                    var success = await DependencyService.Get <ITopupPaymentService>().ProcessCustomerCard(card, Int32.Parse(amount.Replace("£", "")), _credential.User.Email);

                    if (success.Keys.First())
                    {
                        StopBusyIndicator();
                        await DisplayAlert("Success", "Topup Success", "OK");

                        await Navigation.PushAsync(page);
                    }
                    else
                    {
                        StopBusyIndicator();
                        await DisplayAlert("Error", success.Values.First(), "OK");
                    }
                }
            }
        }