/// <summary> /// Checking if it's an employee or a student trying to log in /// </summary> private void CheckLogin() { string password = LogInViewModel.EncryptPassword(PB_InsertPassword.Password); if (Rb_Student.IsChecked == true) { StudentLogIn(password); } else if (Rb_Employee.IsChecked == true) { EmployeeLogIn(password); } }
/// <summary> /// Encrypting password before sending values to be set to the new student /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Bttn_AddStudent_Click(object sender, RoutedEventArgs e) { try { string password = LogInViewModel.EncryptPassword(Pb_Password.Password); AdminViewModel.Instance.SetValuesForStudent(Tb_FirstName.Text, Tb_LastName.Text, Tb_Email.Text, password, int.Parse(Cb_Grade.SelectedValue.ToString())); ClearValues(); } catch (Exception) { await new MessageDialog("Data var felaktigt inmatad, vänligen försök igen.").ShowAsync(); } }
/// <summary> /// Sends the information inside the textboxes to the EditPassword method for handling. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private async void EditPasswordClick(object sender, RoutedEventArgs args) { try { if (passwordBox_Password.Password == "" && passwordBox_repeatPassword.Password == "") { throw new FormatException(); } if (passwordBox_Password.Password == passwordBox_repeatPassword.Password) { string hashPass = LogInViewModel.EncryptPassword(passwordBox_Password.Password); if (chosenPerson.GetType() == typeof(Model.Student)) { adminViewModel.EditPassword((Model.Student)chosenPerson, hashPass); } else if (chosenPerson.GetType() == typeof(Model.Employee)) { adminViewModel.EditPassword((Model.Employee)chosenPerson, hashPass); } } else { await new MessageDialog("Lösenorden stämmer ej").ShowAsync(); } } catch (NullReferenceException) { await new MessageDialog("Välj en person först").ShowAsync(); } catch (FormatException) { await new MessageDialog("Lösenordet får inte vara tomt").ShowAsync(); } catch { await new MessageDialog("Error. Kontakta administratör").ShowAsync(); } }