public void OnAuthRequest(AuthRequestInfo info) { using (DBContext dbContext = new DBContext()) { try { ActiveUser = dbContext.Users.Where(u => u.Login == info.Login && u.Password == info.Password).Single(); } catch { throw new Exception("Неверно указан логин или пароль."); } } }
public void Authentificate() { AuthRequestInfo info = new AuthRequestInfo(comboBox_Login.Text, textBox_Password.Text); try { authManager.OnAuthRequest(info); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (authManager.ActiveUser != null) { Close(); Thread thread = new Thread(() => Application.Run(new FormMain(authManager.ActiveUser))); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } }