示例#1
0
        private async void Handle_SignUp(object sender, RoutedEventArgs e)
        {
            CheckValid valid = new CheckValid();

            currentMember.firstName = this.FirstName.Text;
            currentMember.lastName  = this.LastName.Text;
            currentMember.email     = this.Email.Text;
            currentMember.password  = this.Password.Password.ToString();
            currentMember.avatar    = this.Avatar_Url.Text;
            currentMember.phone     = this.Phone.Text;
            currentMember.address   = this.Address.Text;
            Debug.WriteLine("First Name" + this.FirstName.Text);
            Debug.WriteLine(this.LastName.Text);
            Debug.WriteLine(this.Address.Text);
            if (!valid.CheckValidAll(currentMember))
            {
                List <TextBlock> listMessage = new List <TextBlock>();
                foreach (KeyValuePair <string, string> entry in valid.listError)
                {
                    var       message   = this.FindName(entry.Key);
                    TextBlock textBlock = message as TextBlock;
                    textBlock.Text       = entry.Value;
                    textBlock.Visibility = Visibility.Visible;
                }
            }
            else
            {
                string response = await ApiHandle.Sign_Up(currentMember);

                Debug.WriteLine(response);
                Debug.WriteLine("OK");
            }
        }
示例#2
0
        private async void Handle_Signup(object sender, RoutedEventArgs e)
        {
            var flag = 0;

            if (this.Email.Text == null || this.Email.Text == "")
            {
                Email_Error.Text = "(*)";
                flag             = 1;
            }
            if (this.FirstName == null || this.FirstName.Text == "")
            {
                FirstName_Error.Text = "(*)";
                flag = 1;
            }
            if (this.LastName.Text == null || this.LastName.Text == "")
            {
                LastName_Error.Text = "(*)";
                flag = 1;
            }
            if (this.Phone.Text == null || this.Phone.Text == "")
            {
                Phone_Error.Text = "(*)";
                flag             = 1;
            }

            if (flag == 0)
            {
                currentMember.firstName = this.FirstName.Text;
                currentMember.lastName  = this.LastName.Text;
                currentMember.email     = this.Email.Text;
                currentMember.password  = this.Password.Password.ToString();
                currentMember.avatar    = this.ImageUrl.Text;
                currentMember.phone     = this.Phone.Text;
                currentMember.address   = this.Address.Text;
                var httpResponseMessage = ApiHandle.Sign_Up(this.currentMember);
                if (httpResponseMessage.Result.StatusCode == HttpStatusCode.Created)
                {
                    Debug.WriteLine("Success");
                }
                else
                {
                    //var errorJson = await httpResponseMessage.Result.Content.ReadAsStringAsync();
                    //ErrorResponse errResponse = JsonConvert.DeserializeObject<ErrorResponse>(errorJson);
                    //foreach (var errorField in errResponse.error.Keys)
                    //{
                    //    TextBlock textBlock = this.FindName(errorField) as TextBlock;
                    //    textBlock.Text = errResponse.error[errorField];
                    //}
                }
            }
            else
            {
                Register_error.Text = "Fields (*) can not be null";
            }
        }
示例#3
0
 private async void Handle_Signup(object sender, RoutedEventArgs e)
 {
     this.currentMember.firstName    = this.FirstName.Text;
     this.currentMember.lastName     = this.LastName.Text;
     this.currentMember.email        = this.Email.Text;
     this.currentMember.password     = this.Password.Password.ToString();
     this.currentMember.avatar       = this.ImageUrl.Text;
     this.currentMember.phone        = this.Phone.Text;
     this.currentMember.address      = this.Address.Text;
     this.currentMember.introduction = this.Introduction.Text;
     validateRegister();
     await ApiHandle.Sign_Up(this.currentMember);
 }
示例#4
0
        private async void Handle_Signup(object sender, RoutedEventArgs e)
        {
            // do validate first.
            this.currentMember.firstName    = this.FirstName.Text;
            this.currentMember.lastName     = this.LastName.Text;
            this.currentMember.email        = this.Email.Text;
            this.currentMember.password     = this.Password.Password.ToString();
            this.currentMember.avatar       = this.ImageUrl.Text;
            this.currentMember.phone        = this.Phone.Text;
            this.currentMember.address      = this.Address.Text;
            this.currentMember.introduction = this.Introduction.Text;
            await ApiHandle.Sign_Up(this.currentMember);

            this.Frame.Navigate(typeof(LoginForm));
        }
        private async void Handle_Signup(object sender, RoutedEventArgs e)
        {
            this.currentMember.firstName = this.FirstName.Text;
            this.currentMember.lastName  = this.LastName.Text;
            this.currentMember.email     = this.Email.Text;
            this.currentMember.password  = this.Password.Password.ToString();
            this.currentMember.avatar    = this.ImageUrl.Text;
            this.currentMember.phone     = this.Phone.Text;
            this.currentMember.address   = this.Address.Text;
            await ApiHandle.Sign_Up(this.currentMember);

            MessageDialog msDialog = new MessageDialog("Thành công");

            msDialog.ShowAsync();
        }
示例#6
0
        private async void Handle_Signup(object sender, TappedRoutedEventArgs e)
        {
            Dictionary <String, String> LoginInfor = new Dictionary <string, string>();

            LoginInfor.Add("email", this.Email.Text);
            LoginInfor.Add("password", this.Password.Password);
            LoginInfor.Add("Confirm_Password_Message", this.Confirm_Password.Password);
            LoginInfor.Add("firstName", this.FirstName.Text);
            LoginInfor.Add("lastName", this.LastName.Text);
            LoginInfor.Add("avatar", this.ImageUrl.Text);
            LoginInfor.Add("phone", this.Phone.Text);
            LoginInfor.Add("address", this.Address.Text);

            this.currentMember.email        = Email.Text;
            this.currentMember.password     = Password.Password;
            this.currentMember.introduction = Introduction.Text;
            this.currentMember.firstName    = FirstName.Text;
            this.currentMember.lastName     = LastName.Text;
            this.currentMember.avatar       = ImageUrl.Text;
            this.currentMember.phone        = Phone.Text;
            this.currentMember.address      = Address.Text;

            var httpResponseMessage = ApiHandle.Sign_Up(this.currentMember);

            if (httpResponseMessage.Result.StatusCode == HttpStatusCode.Created)
            {
                Debug.WriteLine("Success a Duy");
            }
            else
            {
                var errorJson = await httpResponseMessage.Result.Content.ReadAsStringAsync();

                ErrorResponse errResponse = JsonConvert.DeserializeObject <ErrorResponse>(errorJson);
                foreach (var errorField in errResponse.error.Keys)
                {
                    TextBlock textBlock = this.FindName(errorField) as TextBlock;
                    textBlock.Text = errResponse.error[errorField];
                }
            }

            //Debug.WriteLine(jsonResult);
            //var rs = JObject.Parse(jsonResult);
            //if ((int)rs["status"] != 201)
            //{
            //    ErrorResponse errResponse = JsonConvert.DeserializeObject<ErrorResponse>(jsonResult);
            //    Debug.WriteLine(errResponse);
            //}
        }
示例#7
0
 private void Handle_Signup(object sender, RoutedEventArgs e)
 {
     // do validate first.
     this.currentMember.firstName    = this.FirstName.Text;
     this.currentMember.lastName     = this.LastName.Text;
     this.currentMember.email        = this.Email.Text;
     this.currentMember.password     = this.Password.Password.ToString();
     this.currentMember.avatar       = this.ImageUrl.Text;
     this.currentMember.phone        = this.Phone.Text;
     this.currentMember.address      = this.Address.Text;
     this.currentMember.introduction = this.Introduction.Text;
     if (ApiHandle.Sign_Up(this.currentMember))
     {
         Debug.WriteLine("Action success.");
     }
 }
示例#8
0
        private async void Do_Register(object sender, TappedRoutedEventArgs e)
        {
            this.currentMember.firstName    = this.FirstName.Text;
            this.currentMember.lastName     = this.LastName.Text;
            this.currentMember.avatar       = this.AvatarUrl.Text;
            this.currentMember.address      = this.Address.Text;
            this.currentMember.introduction = this.Introduction.Text;
            this.currentMember.phone        = this.Phone.Text;
            this.currentMember.email        = this.Email.Text;
            this.currentMember.password     = this.Password.Password;

            var httpResponseMessage = ApiHandle.Sign_Up(this.currentMember);

            if (httpResponseMessage.Result.StatusCode == HttpStatusCode.Created)
            {
                IsValidate = true;
                var dialog = new Windows.UI.Popups.MessageDialog("Bạn đã tạo mới tài khoản thành công");
                dialog.Commands.Add(new Windows.UI.Popups.UICommand("Đóng")
                {
                    Id = 1
                });
                dialog.CancelCommandIndex = 1;
                await dialog.ShowAsync();
            }
            else
            {
                var errorJson = await httpResponseMessage.Result.Content.ReadAsStringAsync();

                Error errResponse = JsonConvert.DeserializeObject <Error>(errorJson);
                if (errResponse.error.Count > 0)
                {
                    foreach (var errorField in errResponse.error.Keys)
                    {
                        if (this.FindName(errorField) is TextBlock textBlock)
                        {
                            textBlock.Text       = "* " + errResponse.error[errorField];
                            textBlock.Visibility = Visibility.Visible;
                            textBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                        }
                    }
                }
            }
        }
示例#9
0
        private async void Handle_Signup(object sender, RoutedEventArgs e)
        {
            // do validate first.
            this.currentMember.firstName    = this.FirstName.Text;
            this.currentMember.lastName     = this.LastName.Text;
            this.currentMember.email        = this.Email.Text;
            this.currentMember.password     = this.Password.Password.ToString();
            this.currentMember.avatar       = this.ImageUrl.Text;
            this.currentMember.phone        = this.Phone.Text;
            this.currentMember.address      = this.Address.Text;
            this.currentMember.introduction = this.Introduction.Text;
            await ApiHandle.Sign_Up(this.currentMember);

            if (this.Email.Text == "")
            {
                this.Email_Message.Text = "Please enter email";
            }
            if (this.Password.ToString() == "")
            {
                this.Password_Message.Text = "Please enter password";
            }
            if (this.FirstName.Text == "")
            {
                this.First_Message.Text = "Please enter firstname";
            }
            if (this.LastName.Text == "")
            {
                this.LastName.Text = "Please enter lastname";
            }
            if (this.Introduction.Text == "")
            {
                this.Introduction_Message.Text = "Please enter introduction";
            }
            if (this.Address.Text == "")
            {
                this.Address_Message.Text = "Please enter address";
            }
            if (this.Phone.Text == "")
            {
                this.Phone_Message.Text = "Please enter phone";
            }
            Debug.WriteLine("Action success.");
        }
示例#10
0
        private async void Handle_Signup(object sender, TappedRoutedEventArgs e)
        {
            this.currentMember.firstName    = this.FirstName.Text;
            this.currentMember.lastName     = this.LastName.Text;
            this.currentMember.email        = this.Email.Text;
            this.currentMember.password     = this.Password.Password.ToString();
            this.currentMember.avatar       = this.ImageUrl.Text;
            this.currentMember.phone        = this.Phone.Text;
            this.currentMember.address      = this.Address.Text;
            this.currentMember.introduction = this.Introduction.Text;

            bool validate = true;

            if (this.currentMember.email == "")
            {
                validate         = false;
                email.Text       = "Email khong duoc de trong!";
                email.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                Email.Focus(FocusState.Programmatic);
            }
            else
            {
                email.Text = "";
            }
            if (this.currentMember.password == "")
            {
                validate            = false;
                password.Text       = "Mat khau khong duoc de trong!";
                password.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                Password.Focus(FocusState.Programmatic);
            }
            else
            {
                password.Text = "";
            }
            if (Confirm_Password.Password.ToString() != Password.Password.ToString())
            {
                validate = false;
                Confirm_Password_Message.Text       = "Ban nhap lai mat khau khong dung";
                Confirm_Password_Message.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                Confirm_Password.Focus(FocusState.Programmatic);
            }
            else
            {
                Confirm_Password_Message.Text = "";
            }

            if (this.currentMember.firstName == "")
            {
                validate             = false;
                firstName.Text       = "firstName khong duoc de trong!";
                firstName.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                FirstName.Focus(FocusState.Programmatic);
            }
            else
            {
                firstName.Text = "";
            }

            if (this.currentMember.lastName == "")
            {
                validate            = false;
                lastName.Text       = "lastName khong duoc de trong!";
                lastName.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                LastName.Focus(FocusState.Programmatic);
            }
            else
            {
                lastName.Text = "";
            }

            if (this.currentMember.avatar == "")
            {
                validate          = false;
                avatar.Text       = "avatar khong duoc de trong!";
                avatar.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                ImageUrl.Focus(FocusState.Programmatic);
            }
            else
            {
                avatar.Text = "";
            }

            if (this.currentMember.address == "")
            {
                validate           = false;
                address.Text       = "Dia chi khong duoc de trong!";
                address.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                Address.Focus(FocusState.Programmatic);
            }
            else
            {
                address.Text = "";
            }

            if (this.currentMember.phone == "")
            {
                validate         = false;
                phone.Text       = "So dien thoai khong duoc de trong!";
                phone.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                Phone.Focus(FocusState.Programmatic);
            }
            else
            {
                phone.Text = "";
            }
            if (validate)
            {
                if (await ApiHandle.Sign_Up(this.currentMember))
                {
                    Debug.WriteLine("Action success.");
                    Login login = new Login();
                    await login.ShowAsync();
                }
                else
                {
                    validate         = false;
                    email.Text       = "Invalid email format!";
                    email.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                    Email.Focus(FocusState.Programmatic);
                }
            }

            //if (httpResponseMessage.Result.StatusCode == HttpStatusCode.Created)
            //{
            //    Debug.WriteLine("Success");
            //}
            //else
            //{
            //    var errorJson = await httpResponseMessage.Result.Content.ReadAsStringAsync();
            //    ErrorResponse errResponse = JsonConvert.DeserializeObject<ErrorResponse>(errorJson);
            //    foreach (var errorField in errResponse.error.Keys)
            //    {
            //        TextBlock textBlock = this.FindName(errorField) as TextBlock;
            //        textBlock.Text = errResponse.error[errorField];
            //    }
            //}

            //Debug.WriteLine(jsonResult);
            //var rs = JObject.Parse(jsonResult);
            //if ((int)rs["status"] != 201)
            //{
            //    ErrorResponse errResponse = JsonConvert.DeserializeObject<ErrorResponse>(jsonResult);
            //    Debug.WriteLine(errResponse);
            //}
        }
示例#11
0
        private async void Handle_Signup(object sender, RoutedEventArgs e)
        {
            Dictionary <String, String> RegisterInfor = new Dictionary <string, string>();

            RegisterInfor.Add("email", this.Email.Text);
            RegisterInfor.Add("firstName", this.FirstName.Text);
            RegisterInfor.Add("lastName", this.LastName.Text);

            this.currentMember.firstName    = this.FirstName.Text;
            this.currentMember.lastName     = this.LastName.Text;
            this.currentMember.email        = this.Email.Text;
            this.currentMember.password     = this.Password.Password.ToString();
            this.currentMember.avatar       = this.ImageUrl.Text;
            this.currentMember.phone        = this.Phone.Text;
            this.currentMember.address      = this.Address.Text;
            this.currentMember.introduction = this.Introduction.Text;
            await ApiHandle.Sign_Up(this.currentMember);

            HttpClient    httpClient      = new HttpClient();
            StringContent content         = new StringContent(JsonConvert.SerializeObject(RegisterInfor), System.Text.Encoding.UTF8, "application/json");
            var           response        = httpClient.PostAsync(API_Register, content).Result;
            var           responseContent = await response.Content.ReadAsStringAsync();

            Debug.WriteLine("Action success.");

            ErrorResponse errorObject = JsonConvert.DeserializeObject <ErrorResponse>(responseContent);

            if (errorObject != null && errorObject.error.Count > 0)
            {
                foreach (var key in errorObject.error.Keys)
                {
                    var textMessage = this.FindName(key);
                    if (textMessage == null)
                    {
                        continue;
                    }
                    TextBlock textBlock = textMessage as TextBlock;
                    textBlock.Text       = errorObject.error[key];
                    textBlock.Visibility = Visibility.Visible;
                }
            }

            if (this.Email.Text == "")
            {
                this.error_Email.Text = "Please enter introduction";
                this.email.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.email.Visibility = Visibility.Visible;
            };

            if (this.Password.ToString() == "")
            {
                this.error_Password.Text = "Please enter introduction";
            }
            if (this.FirstName.Text == "")
            {
                this.error_Fname.Text     = "Please enter introduction";
                this.firstName.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.firstName.Visibility = Visibility.Visible;
            };
            if (this.LastName.Text == "")
            {
                this.error_Lname.Text    = "Please enter introduction";
                this.lastName.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.lastName.Visibility = Visibility.Visible;
            }
            if (this.Introduction.Text == "")
            {
                this.error_Intro.Text = "Please enter introduction";
            }
            if (this.Address.Text == "")
            {
                this.error_Add.Text = "Please enter introduction";
            }
            if (this.Phone.Text == "")
            {
                this.error_Phone.Text = "Please enter introduction";
            }
        }
示例#12
0
        private async void Register_Button(object sender, RoutedEventArgs e)
        {
            var username        = Username.Text;
            var password        = Password.Password;
            var confirmpassword = ConfirmPassword.Password;
            var fullname        = Fullname.Text;
            var email           = Email.Text;
            var birthday        = BirthDay.Date;
            var avatar          = "";

            if (ChooseAvatar.Content.ToString() != "Choose File")
            {
                avatar = ChooseAvatar.Content.ToString();
            }
            ;
            if (username == "")
            {
                Username_Message.Text = "Username is empty.";
            }
            else
            {
                Username_Message.Text = "";
                this.account.username = username;
            };
            if (password == "")
            {
                Password_Message.Text = "Password is empty.";
            }
            else
            {
                Password_Message.Text = "";
            };
            if (confirmpassword != password)
            {
                ConfirmPassword_Message.Text = "Confirm Password does not match";
            }
            else
            {
                ConfirmPassword_Message.Text = "";
                this.account.password        = password;
            };
            if (fullname == "")
            {
                Fullname_Message.Text = "Full Name is empty.";
            }
            else
            {
                Fullname_Message.Text = "";
                this.account.fullname = fullname;
            };
            if (!ValidateEmail(email))
            {
                Email_Message.Text = "Email invalid.";
            }
            else
            {
                Email_Message.Text = "";
                this.account.email = email;
            };
            if (birthday >= DateTime.Today)
            {
                BirthDay_Message.Text = "Birth Day invalid.";
            }
            else
            {
                BirthDay_Message.Text = "";
                this.account.birthday = birthday.ToString();
            }
            if (Username_Message.Text == "" && Password_Message.Text == "" && ConfirmPassword_Message.Text == "" && Fullname_Message.Text == "" && Email_Message.Text == "" && birthday < DateTime.Today)
            {
                if (await ApiHandle.CheckExistsUsername(this.account.username))
                {
                    var response = await ApiHandle.Sign_Up(this.account);

                    Debug.WriteLine(response);
                    Username_Message.Text = "";
                    ContentDialog uploadSuccess = new ContentDialog()
                    {
                        Title           = "Register success!",
                        CloseButtonText = "Ok"
                    };

                    await uploadSuccess.ShowAsync();
                }
                else
                {
                    Username_Message.Text = "Username exists.";
                }
            }
        }