Beispiel #1
0
 private async void createButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (validModel.checkLogin(loginBox.Text) && validModel.checkEmail(emailBox.Text) && validModel.checkName(nameBox.Text) && validModel.checkSurname(surnameBox.Text) && validModel.checkPhoneNumber(phoneBox.Text) && validModel.checkPassword(passwordBox.Password.ToString()))
         {
             if (!model.emailExist(emailBox.Text) && !model.loginExist(loginBox.Text))
             {
                 MainWindow mainWin = new MainWindow();
                 mainWin.Show();
                 this.Close();
                 User user = new User()
                 {
                     login       = loginBox.Text,
                     email       = emailBox.Text,
                     name        = nameBox.Text,
                     surname     = surnameBox.Text,
                     phoneNumber = phoneBox.Text,
                     password    = model.GetMd5Hash(md5Hash, passwordBox.Password.ToString())
                 };
                 db.User.Add(user);
                 await db.SaveChangesAsync();
             }
         }
     }
     catch (Exception except)
     {
         MessageBox.Show(except.Message);
     }
 }
Beispiel #2
0
 private void loginButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (validModel.checkLogin(loginBox.Text) && validModel.checkPassword(passwordBox.Password.ToString()))
         {
             if (model.loginExist(loginBox.Text) && model.checkPassword(md5Function.GetMd5Hash(md5hash, passwordBox.Password.ToString())))
             {
                 loggedWindow loggedWin = new loggedWindow(model.getID(loginBox.Text));
                 loggedWin.Show();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Email lub hasło są niepoprawne!");
             }
         }
     }
     catch (Exception expect)
     {
         MessageBox.Show(expect.Message);
     }
 }