Пример #1
0
        private async void PassportRegisterButton_Click(object sender, RoutedEventArgs e)
        {
            UserName     = UsernameTextBox.Text;
            Userpassword = UserpasswordTextBox.Text;
            Email        = UserEmailTextBox.Text;

            UserRegister register = new UserRegister(UserName, Userpassword, Email);
            bool         result   = await Service.SignUp(register);

            if (result)
            {
                Frame.Navigate(typeof(Login), null);
            }
            else
            {
                DialogCreator.CreateDialog("登录失败", "请重新登录");
            }
            //todo 注册到服务器
        }
Пример #2
0
        private async void  SignInPassport()
        {
            //需要判断从哪里加载用户
            UserLogin user = null;

            if (!_isExistingAccount)
            {
                UserName     = UsernameTextBox.Text;
                UserPassword = UserpasswordTextBox.Text;
                user         = new UserLogin(UserName, UserPassword);
            }
            else
            {
                UsernameTextBox.Text     = UserLogin.Email;
                UserpasswordTextBox.Text = UserLogin.Password;
                user = UserLogin;
            }

            //暂时默认为成功

            bool result = await Service.Login(user);

            if (result && UserAccountHelper.CheckCredential(user))
            {
                if (!_isExistingAccount)
                {
                    UserAccountHelper.AddAccount(user);
                    UserAccountHelper.SaveAccountListAsync();
                }
                Debug.WriteLine("the size of the list" + UserAccountHelper.UserAccounts.Count);
                Frame.Navigate(typeof(MainPage), null);
            }
            else
            {
                DialogCreator.CreateDialog("登陆失败",
                                           "登录失败请重新尝试");
            }
        }