示例#1
0
        private async void OnbtnSendCode(object sender, EventArgs e)
        {
            var MobileNo = string.Empty;

            MobileNo = txtMobileNo.Text;
            string ValidationMsg = "";
            bool   IsValid       = true;

            if (MobileNo == null)
            {
                ValidationMsg += "Enter Mobile\n";
                IsValid        = false;
            }
            else
            {
                if (!CheckValidMobile(MobileNo))
                {
                    ValidationMsg += "Enter 9 digit mobile no.\n";
                    IsValid        = false;
                }
            }

            if (IsValid)
            {
                dsLogin = new F4HApp.dataservice.DSLogin();
                string result = await dsLogin.ChkMobileExists(MobileNo);

                RegistrationResponseObject m = JsonConvert.DeserializeObject <RegistrationResponseObject>(result.Replace("[", "").Replace("]", ""));
                string Status = m.Status.ToString();
                string Msg    = m.Msg;

                if (Status == "Success")
                {
                    IntRandom = RandomNumber(1, 9999);
                    string Message = @"Your OTP is " + IntRandom.ToString();

                    string SMSResult = await dsLogin.SendSms(MobileNo, Message);

                    SMSResponceObject S = JsonConvert.DeserializeObject <SMSResponceObject>(SMSResult.Replace("[", "").Replace("]", ""));

                    string SmsStatusAlert = S.Status.ToString();
                    await DisplayAlert("Food4Health - OTP ", IntRandom.ToString(), "Done");

                    StackMobileNo.IsVisible = false;
                    StackReset.IsVisible    = false;
                    StackOTP.IsVisible      = true;
                }
                else
                {
                    await DisplayAlert("Validation Error", "Mobile number not found", "Re-try");
                }
            }
            else
            {
                await DisplayAlert("Validation Error", ValidationMsg, "Re-try");
            }
        }