public async void SendVerify_Clicked(object sender, EventArgs e)
        {
            var phone = EntryPhone.Text?.Trim();

            if (string.IsNullOrEmpty(phone))
            {
                await DisplayAlert("", "Vui lòng nhập số điện thoại", "Đóng");
            }
            else if (phone.Length < 9)
            {
                await DisplayAlert("", "Số điện thoại không hợp lệ", "Đóng");
            }
            else
            {
                var ran = new Random();
                VerifyCode = $"{ran.Next(0, 9)}{ran.Next(0, 9)}{ran.Next(0, 9)}{ran.Next(0, 9)}";
                ApiResponse response = await ApiHelper.Post($"api/user/confirmphoneandsendcode/{VerifyCode}/{phone}", null);

                if (response.IsSuccess)
                {
                    VerifyPopup.IsVisible = true;
                    EntryVerifyCode.Focus();
                }
                else
                {
                    await DisplayAlert("", response.Message, "Đóng");
                }
            }
        }
Ejemplo n.º 2
0
        private async void Register_Clicked(object sender, EventArgs e)
        {
            //viewModel.LoadAccountTabPage();
            var mainPage = Shell.Current;

            if (string.IsNullOrEmpty(viewModel.RegisterModel.FullName))
            {
                await mainPage.DisplayAlert("", "Vui lòng nhập họ tên", "Đóng");

                return;
            }
            else if (string.IsNullOrEmpty(viewModel.RegisterModel.Email))
            {
                await mainPage.DisplayAlert("", "Vui lòng nhập Email", "Đóng");

                return;
            }
            else if (string.IsNullOrEmpty(viewModel.RegisterModel.Phone))
            {
                await mainPage.DisplayAlert("", "Vui lòng nhập số điện thoại", "Đóng");

                return;
            }
            else if (string.IsNullOrEmpty(viewModel.RegisterModel.Password))
            {
                await mainPage.DisplayAlert("", "Vui lòng nhập mật khẩu", "Đóng");

                return;
            }
            else
            {
                string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
                                           + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
                                           + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";

                var rg = new Regex(validEmailPattern, RegexOptions.IgnoreCase);

                bool isValid = rg.IsMatch(viewModel.RegisterModel.Email);
                if (isValid == false)
                {
                    await mainPage.DisplayAlert("", "Email không đúng định dạng", "Đóng");

                    return;
                }
            }

            //viewModel.customTabbed_Login.ShowLoading(true);
            var checkExistResponse = await ApiHelper.Post($"api/user/checkphoneemail/{viewModel.RegisterModel.Phone}/{viewModel.RegisterModel.Email}", null, false);

            if (checkExistResponse.IsSuccess)
            {
                VerifyPopup.IsVisible = true;
                EntryVerifyCode.Text  = "";
                EntryVerifyCode.Focus();
                SendVerifyCode(viewModel.RegisterModel.Phone);
            }
            else
            {
                string ErrorMesage = checkExistResponse.GetFirstErrorMessage();
                if (string.IsNullOrEmpty(ErrorMesage))
                {
                    ErrorMesage = "Vui lòng thử lại";
                }
                await mainPage.DisplayAlert("", ErrorMesage, "Đóng");
            }
            //viewModel.customTabbed_Login.ShowLoading(false);
        }
Ejemplo n.º 3
0
        public async void UpdateProfile_Clicked(object sender, EventArgs e)
        {
            var fullName = EntryName.Text?.Trim();
            var phone    = EntryPhone.Text?.Trim();
            var address  = EntryAddress.Text?.Trim();


            if (string.IsNullOrEmpty(fullName))
            {
                await DisplayAlert("", "Vui lòng cung câp họ tên", "Đóng");

                return;
            }

            if (EntryEmail.IsEnabled)
            {
                var email = EntryEmail.Text.Trim();
                if (string.IsNullOrWhiteSpace(email))
                {
                    await DisplayAlert("", "Vui lòng cung cấp Email", "Đóng");

                    return;
                }

                string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
                                           + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
                                           + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";

                var rg = new Regex(validEmailPattern, RegexOptions.IgnoreCase);

                bool isValid = rg.IsMatch(email);
                if (!isValid)
                {
                    await DisplayAlert("", "Email không đúng định dạng", "Đóng");

                    return;
                }

                var checkPhoneResposne = await ApiHelper.Post($"api/user/checkemail/{email}", null, true);

                if (checkPhoneResposne.IsSuccess == false)
                {
                    gridLoading.IsVisible = false;
                    await DisplayAlert("", checkPhoneResposne.GetFirstErrorMessage(), "Đóng");

                    return;
                }
            }

            if (string.IsNullOrEmpty(phone))
            {
                await DisplayAlert("", "Vui lòng cung cấp số điện thoại", "Đóng");

                return;
            }
            if (string.IsNullOrEmpty(address))
            {
                await DisplayAlert("", "Vui lòng cung cấp địa chỉ", "Đóng");

                return;
            }

            gridLoading.IsVisible = true;



            if (UserLogged.Phone != phone) // co thay doi so dien thoai.
            {
                // kiem tra so dien thoai avaiable.

                var checkPhoneResposne = await ApiHelper.Post($"api/user/checkphoneemail/{phone}/1", null, true);

                if (checkPhoneResposne.IsSuccess == false)
                {
                    gridLoading.IsVisible = false;
                    await DisplayAlert("", checkPhoneResposne.GetFirstErrorMessage(), "Đóng");

                    return;
                }

                VerifyPopup.IsVisible = true;
                EntryVerifyCode.Text  = "";
                EntryVerifyCode.Focus();
                SendVerifyCode(phone);
                gridLoading.IsVisible = false;
            }
            else
            {
                SaveProfile();
            }
        }