Esempio n. 1
0
        public void ProcessLogin(string userPass)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Usercode.Text))
                {
                    MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Usercode.Focus();
                    return;
                }

                var userLoginSuccessful = _loginService.Login(userPass, "user");
                if (userLoginSuccessful == null)
                {
                    MessageBox.Show(@"Wrong PassCode", @"information!", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    Usercode.Text = "";
                    Usercode.Focus();
                    return;
                }
                _stateService.SetCurrentlyLoggedInUser(userLoginSuccessful);
                _testEvaluationService.UserInProgress(userLoginSuccessful);

                this.Hide();
                var testPage = Program.CreateServiceProvider().GetRequiredService <TestPage>();
                testPage.Show();
            }
            catch (SqlException exception)
            {
                MessageBox.Show(exception.Message, "information!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }