Exemple #1
0
 private void btnSubmit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string username      = ValidateUser.ValidateUsername(tbUsername.Text);
         string password      = ValidateUser.ValidateNewPassword(pbPassword.Password);
         string passwordAgain = pbPasswordAgain.Password;
         if (password == passwordAgain)
         {
             if (Authentification.NewUser(username, pbPassword.Password, comboBoxRoles.Text))
             {
                 DialogHelper.ShowInfo("Uživatel úspěšně přidán.");
                 this.Close();
             }
             else
             {
                 throw new NotImplementedException();
             }
         }
         else
         {
             DialogHelper.ShowWarning("Hesla se neshodují");
             pbPasswordAgain.Password = string.Empty;
         }
     }
     catch (InvalidUsernameException ex)
     {
         DialogHelper.ShowWarning(ex.Message);
     }
     catch (InvalidAuthPasswordException ex)
     {
         DialogHelper.ShowWarning(ex.Message);
     }
     catch
     {
         DialogHelper.ShowError("Uživatel nemohl být přidán.");
     }
 }