private void CheckAdviceExistInDataBase(string nameAdvice) { var adviceMainWin = new AdviceMainWindow(); string name = adviceMainWin.ListOfAdvices.Select(m => m as string).Where(k => k.Equals(nameAdvice)).FirstOrDefault(); if (string.IsNullOrEmpty(name)) { throw new Exception("The advice not found! expected result " + nameAdvice); } }
/// <summary> /// LogIn Button to the Caunselor System /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClickLogInButton(object sender, RoutedEventArgs e) { try { string inputUserName = UserNameText.Text.ToUpper(); string inputPassword = PasswordText.Password.ToString(); string inputRole = RoleComboBox.Text; if (inputRole.Equals(REGULAR_USER_STRING)) { var adviceWindow = new AdviceMainWindow(); adviceWindow.Show(); this.Close(); } else { CheckInputLogInWindow(inputUserName, inputPassword, inputRole); string userFromDB = GetUserNameFromDB(inputUserName); string passwordFromDB = GetUserPasswordDB(inputUserName); string roleFromDB = GetRoleFromDB(inputUserName); if (inputRole.Equals(MASTER_STRING)) { inputRole = MASTER_CODE; } if (inputUserName.Equals(userFromDB) && inputPassword.Equals(passwordFromDB) && inputRole.Equals(roleFromDB)) { var admin = new AdminMainWindow(userFromDB); admin.Show(); this.Close(); } else { ErrorLebal.Content = "One of the values is incorrect!"; ErrorLebal.Visibility = Visibility.Visible; throw new Exception("One of the values is incorrect"); } } Logger.Instance.Info("ClickLogInButton()"); } catch (Exception ex) { Logger.Instance.Error("Error while tyring to click log in ", ex); } }