Ejemplo n.º 1
0
        private async void _Submit_Clicked(object sender, EventArgs e)
        {
            try
            {
                String PhoneNo = _CountryCode.SelectedItem + _PhoneNo.Text;

                if (!String.IsNullOrEmpty(PhoneNo) && !String.IsNullOrEmpty(_ConfirmPassword.Text))
                {
                    String Email = (String.IsNullOrEmpty(_Email.Text)) ? "n/a" : _Email.Text;
                    //inform user if email/phone no is used
                    bool IsEmailAvail = false;

                    if (Email != "n/a")
                    {
                        IsEmailAvail = await SignUpController.CheckUniqueFields(Utilities.PostDataEncoder(new Dictionary <int, string[]>
                        {
                            { 0, new String[] { "email", _Email.Text } }
                        }), "e-mail");
                    }

                    bool IsPhoneAvail = await SignUpController.CheckUniqueFields(Utilities.PostDataEncoder(new Dictionary <int, string[]>
                    {
                        { 0, new String[] { "phone", PhoneNo } }
                    }), "phone-no");


                    if (IsEmailAvail)
                    {
                        if (IsPhoneAvail)
                        {
                            //confirm password
                            if (_ConfirmPassword.Text.Equals(_Password.Text))
                            {
                                await Navigation.PushAsync(new OTPPage(new GeneralDetails(Email, PhoneNo, _ConfirmPassword.Text, UserType, ShortCountryCode)));
                            }
                            else
                            {
                                await DisplayAlert("Alert", "Passwords don't match", "Okay");
                            }
                        }
                        else
                        {
                            await DisplayAlert("Alert", "Phone number is already registered ", "Okay");
                        }
                    }
                    else
                    {
                        await DisplayAlert("Alert", "Email address is already registered ", "Okay");
                    }
                }
                else
                {
                    //force validation
                    if (String.IsNullOrEmpty(_PhoneNo.Text))
                    {
                        _PhoneNo.PlaceholderColor = Color.Red;
                    }
                    else
                    {
                        _PhoneNo.PlaceholderColor = Color.Black;
                    }

                    if (String.IsNullOrEmpty(_Password.Text))
                    {
                        _Password.PlaceholderColor = Color.Red;
                    }
                    else
                    {
                        _Password.PlaceholderColor = Color.Black;
                    }

                    if (String.IsNullOrEmpty(_ConfirmPassword.Text))
                    {
                        _ConfirmPassword.PlaceholderColor = Color.Red;
                    }
                    else
                    {
                        _ConfirmPassword.PlaceholderColor = Color.Black;
                    }

                    await DisplayAlert("Alert", "Pleae fill the RED Fields", "Okay");
                }
            }
            catch (System.Net.WebException WebEx)
            {
                await DisplayAlert("Alert", Utilities.NoInternet, "Okay");
            }
            catch (Exception ex)
            {
                await DisplayAlert("Alert", ex.Message, "Okay");
            }
        }