Пример #1
0
        private async void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (CheckLogin(this.Email.Text))
            {
                Revert();
                Dictionary <String, String> LoginInfo = new Dictionary <string, string>();
                LoginInfo.Add("email", this.Email.Text);
                LoginInfo.Add("password", this.Password.Password);
                string responseContent = await ApiHandle <Dictionary <string, string> > .Call(APITypes.SignIn, LoginInfo);

                try
                {
                    Response resp = JsonConvert.DeserializeObject <Response>(responseContent);
                    if (resp.token != null)
                    {
                        if (rem.IsChecked == true)
                        {
                            await FileHandle.Save("token.ini", resp.token);
                        }
                        FrameSwitcher.Switch(typeof(Views.NavigationView));
                    }
                    else
                    {
                        Entity.Exception err = JsonConvert.DeserializeObject <Entity.Exception>(responseContent);
                        login.Text       = err.message;
                        login.Visibility = Visibility.Visible;
                    }
                }
                catch
                {
                    ApiHandle <string> .ThrowException(responseContent);
                }
            }
            else
            {
                email.Visibility = Visibility.Visible;
            }
        }
Пример #2
0
        private async void Handle_Signup(object sender, RoutedEventArgs e)
        {
            if (CheckRegister(this.Email.Text, this.Phone.Text))
            {
                Revert();
                this.currentMember.firstName    = this.FirstName.Text;
                this.currentMember.lastName     = this.LastName.Text;
                this.currentMember.email        = this.Email.Text;
                this.currentMember.password     = this.Password.Password;
                this.currentMember.avatar       = this.ImageUrl.Text;
                this.currentMember.phone        = this.Phone.Text;
                this.currentMember.address      = this.Address.Text;
                this.currentMember.introduction = this.Introduction.Text;
                string responseContent = await ApiHandle <Member> .Call(APITypes.SignUp, this.currentMember);

                try
                {
                    Member resp = JsonConvert.DeserializeObject <Member>(responseContent);
                    if (resp.email != null && resp.email == this.currentMember.email)
                    {
                        await Dialog.Show("Register success!");

                        FrameSwitcher.Switch(typeof(Views.LoginForm));
                    }
                    else
                    {
                        Entity.Exception err = JsonConvert.DeserializeObject <Entity.Exception>(responseContent);
                        register.Text       = err.message;
                        register.Visibility = Visibility.Visible;
                    }
                }
                catch
                {
                    ApiHandle <string> .ThrowException(responseContent);
                }
            }
        }
Пример #3
0
 private void BtnBack_Click(object sender, RoutedEventArgs e)
 {
     FrameSwitcher.Switch(typeof(Views.LoginForm));
 }
Пример #4
0
 private void BtnReset_Click(object sender, RoutedEventArgs e)
 {
     FrameSwitcher.Switch(typeof(Views.RegisterForm));
 }
Пример #5
0
 private async void BtnSignUp_Click(object sender, RoutedEventArgs e)
 {
     FrameSwitcher.Switch(typeof(Views.RegisterForm));
 }