private void Login() { try { int roleId = loginViewModel.GetLoginRole(UsernameTextBox.Text, Crypto.ConvertToHash(PasswordTextBox.Password)); if (roleId > 0) { // Report all action data ActionLogger.ReportAllDataNow(); // Add login action to action logger ActionLogger.Log(GetType().FullName + nameof(Login), UsernameTextBox.Text, roleId, $"<User_Login>"); // Open admin main view foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { (window as MainWindow).MainContentControl.DataContext = new AdminMainView(roleId, UsernameTextBox.Text); } } } else { NotifyInvalidLoginCredentials(); } } catch { NotifyInvalidLoginCredentials(); } }