示例#1
0
        private async void submitButton_Clicked(object sender, EventArgs e)
        {
            //Validation Part
            string msg = string.Empty;

            string birthOfYear = txtCreateNwAccnDOB.Text;

            string postalCode = txtCreateNwAccnPostalCode.Text;



            if (string.IsNullOrEmpty(postalCode))
            {
                msg = Resx.AppResources.validPostalCode + Environment.NewLine;
            }

            else
            {
                if (postalCode.Length < 5 || postalCode.Length > 5)
                {
                    msg = Resx.AppResources.postalcodefivedigit + Environment.NewLine;
                }
                else
                {
                    try
                    {
                        if (!CommonLib.checkconnection())
                        {
                            await App.Current.MainPage.DisplayAlert("", Resx.AppResources.checkInternet, "OK");

                            return;
                        }
                        await Navigation.PushPopupAsync(new LoadPopup());

                        string postData = "postalCode=" + postalCode;
                        var    result   = await CommonLib.GetProvince(CommonLib.ws_MainUrl + "GetProvinceName?" + postData);

                        if (result.Status == 1)
                        {
                            LoadPopup.CloseAllPopup3();
                        }
                        else
                        {
                            LoadPopup.CloseAllPopup3();
                            msg = Resx.AppResources.validPostalCode + Environment.NewLine;
                        }
                    }
                    catch (Exception ex)
                    {
                        LoadPopup.CloseAllPopup3();
                        await App.Current.MainPage.DisplayAlert("", ex.Message, "OK");
                    }
                }
            }
            if (string.IsNullOrEmpty(birthOfYear))
            {
                msg = Resx.AppResources.selectBirthYear + Environment.NewLine;
            }
            if (string.IsNullOrEmpty(genderType))
            {
                msg = Resx.AppResources.pleaseselectgender + Environment.NewLine;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                await App.Current.MainPage.DisplayAlert("", msg, "OK");

                return;
            }
            try
            {
                await Navigation.PushPopupAsync(new LoadPopup());

                var result = await CommonLib.ChangePostalCode(CommonLib.ws_MainUrl + "UpdateDobAndPostal?" + "Id=" + LoginDetails.userId + "&Code=" + postalCode + "&Dob=" + birthOfYear + "&gender=" + genderType);

                if (result.Status != 0)
                {
                    await App.Current.MainPage.DisplayAlert("", Resx.AppResources.Sucess, "OK");

                    LoadPopup.CloseAllPopup();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("", ex.Message, "OK");
            }
        }
        public async void PackageDetails()
        {
            try
            {
                await Navigation.PushPopupAsync(new LoadPopup());



                var result = await CommonLib.GetPackage(CommonLib.ws_MainUrlMain + "PackageApi/GetPackage");

                if (result != null && result.Status != 0)
                {
                    price = result.details.PackagePrice;

                    try
                    {
                        string msg = string.Empty;
                        if (string.IsNullOrEmpty(txtcardNumber.Text))
                        {
                            msg += Resx.AppResources.entercard + Environment.NewLine;
                        }
                        else
                        {
                            if (txtcardNumber.Text.Length != 16)
                            {
                                msg += Resx.AppResources.entervalidcard + Environment.NewLine;
                            }
                        }
                        if (string.IsNullOrEmpty(txtCVVNumber.Text))
                        {
                            msg += Resx.AppResources.entercvv + Environment.NewLine;
                        }
                        else
                        {
                            if (txtCVVNumber.Text.Length != 3)
                            {
                                msg += Resx.AppResources.entervalidcvv + Environment.NewLine;
                            }
                        }
                        if (string.IsNullOrEmpty(txtMonth.Text))
                        {
                            msg += Resx.AppResources.entermonth + Environment.NewLine;
                        }
                        else
                        {
                            if (Convert.ToInt32(txtMonth.Text) > 12)
                            {
                                msg += Resx.AppResources.entervalidmonth + Environment.NewLine;
                            }
                        }
                        if (string.IsNullOrEmpty(txtYear.Text))
                        {
                            msg += Resx.AppResources.enteryear + Environment.NewLine;
                        }
                        else
                        {
                            int curYear = Convert.ToInt32(DateTime.Now.Year.ToString().Substring(1));
                            if (Convert.ToInt32(txtYear.Text) < curYear)
                            {
                                msg += Resx.AppResources.entervalidyear + Environment.NewLine;
                            }
                        }
                        if (!string.IsNullOrEmpty(msg))
                        {
                            LoadPopup.CloseAllPopup3();
                            await App.Current.MainPage.DisplayAlert("", msg, "OK");

                            return;
                        }


                        StripeCardInfo cardInfo = new StripeCardInfo();
                        cardInfo.CardNumber = txtcardNumber.Text;
                        cardInfo.CCV        = txtCVVNumber.Text;
                        cardInfo.Month      = Convert.ToInt32(txtMonth.Text);
                        cardInfo.Year       = Convert.ToInt32(txtYear.Text);


                        double Amount = Convert.ToDouble(price);


                        var paymentresult = await DependencyService.Get <ICustomStripeService>().MakePayment(cardInfo, Amount);


                        if (!paymentresult.IsPaid)
                        {
                            LoadPopup.CloseAllPopup3();
                            MyProfilePage.checkPremimun = false;

                            await App.Current.MainPage.DisplayAlert("", paymentresult.FailureMessage, "OK");



                            return;
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("", Resx.AppResources.PaymentSuccessful, "OK");


                            MyProfilePage.checkPremimun = true;
                            PremimumUser();
                        }
                    }
                    catch (Exception)
                    {
                    }


                    LoadPopup.CloseAllPopup1();
                }

                else
                {
                    LoadPopup.CloseAllPopup1();
                }
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("", ex.Message, "OK");

                LoadPopup.CloseAllPopup1();
            }
        }