Beispiel #1
0
        public static async Task <string> RegisterAsync()
        {
            RegistrationResponse registrationResponse = await NetworkHandler.RegisterAsync();

            if (registrationResponse == RegistrationResponse.Success)
            {
                IsLoggedIn = true;
                return(null);
            }
            else if (registrationResponse == RegistrationResponse.UserExists)
            {
                IsLoggedIn = false;
                return("A user with this username allready exists.");
            }
            else
            {
                IsLoggedIn = false;
                return("Error registering you. Try again later.");
            }
        }
Beispiel #2
0
        private async void DeleteNote()
        {
            var response = await NetworkHandler.DeleteNoteAsync(_currentNote);

            switch (response)
            {
            case DeleteNoteRespnse.Success:
                UserData.Notes.Remove(_currentNote);
                CloseNote();
                break;

            case DeleteNoteRespnse.Unauthanticated:
                break;

            case DeleteNoteRespnse.Error:
                break;

            default:
                break;
            }
        }
        private async void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            if (Password.Password == PasswordConfirm.Password && Username.Text.Length > 4 && Password.Password.Length > 4)
            {
                User.username = Username.Text;
                User.password = Password.Password;
                NetworkHandler.Initialize();
                string response = await User.RegisterAsync();

                if (response == null)
                {
                    await UserData.SaveUser();

                    Close();
                }
                else
                {
                    WarningText.Text       = response;
                    WarningText.Visibility = Visibility.Visible;
                }
            }
            else if (Password.Password != PasswordConfirm.Password)
            {
                WarningText.Text       = "Passwords do not match!";
                WarningText.Visibility = Visibility.Visible;
            }
            else if (Username.Text.Length <= 4)
            {
                WarningText.Text       = "Username is too short!";
                WarningText.Visibility = Visibility.Visible;
            }
            else
            {
                WarningText.Text       = "Password is too short!";
                WarningText.Visibility = Visibility.Visible;
            }
        }
Beispiel #4
0
 private async void Reload_Click(object sender, RoutedEventArgs e)
 {
     await NetworkHandler.LoadAllNotesAsync();
 }