Пример #1
0
        private void ResetPassword()
        {
            Encryptor encryptor = new Encryptor();

            StudentService.StudentServiceClient studentService = new StudentService.StudentServiceClient();

            string userToken = CreateUserToken();

            ResponseModel <string> confirmResetResponseModel = encryptor.ResponseDeserializer <string>
                                                                   (studentService.ConfirmReset(userToken, newPasswordTextBox.Text));

            if (confirmResetResponseModel.IsSuccess)
            {
                passwordResetLabel.Text = confirmResetResponseModel.Model;

                passwordResetLabel.Visible     = true;
                newPasswordTextBox.Enabled     = false;
                confirmPasswordTextBox.Enabled = false;
                resetButton.Visible            = false;
            }
            else
            {
                if (!string.IsNullOrEmpty(confirmResetResponseModel.ErrorAction) &&
                    confirmResetResponseModel.ErrorAction.Equals("[LinkExpired]"))
                {
                    ToggleExpired();
                }
                else
                {
                    MessageBox.Show(confirmResetResponseModel.OutputMessage);
                }
            }
        }
Пример #2
0
        private void SetConnection()
        {
            StudentService.StudentServiceClient studentService = new StudentService.StudentServiceClient();

            isConnected = studentService.CheckConnection();

            if (!isConnected)
            {
                studentService.Abort();
                this.Close();
            }
        }
Пример #3
0
        private void ActivateLink()
        {
            Encryptor encryptor = new Encryptor();

            StudentService.StudentServiceClient studentServiceClient = new StudentService.StudentServiceClient();

            ResponseModel <string> linkResponseModel = encryptor.ResponseDeserializer <string>
                                                           (studentServiceClient.ActivateLink(username, token));

            if (linkResponseModel.IsSuccess)
            {
                ConfirmReset confirmResetWindow = new ConfirmReset(linkResponseModel.Model);
                confirmResetWindow.Show();
            }
            else
            {
                MessageBox.Show(linkResponseModel.OutputMessage);
            }
        }
Пример #4
0
        private void GetLogin()
        {
            Encryptor encryptor = new Encryptor();

            StudentService.StudentServiceClient studentService = new StudentService.StudentServiceClient();

            ResponseModel <UserModel> userResponseModel = encryptor.ResponseDeserializer <UserModel>
                                                              (studentService.Login(usernameTextBox.Text, passwordTextBox.Text));

            if (userResponseModel.IsSuccess)
            {
                userModel       = userResponseModel.Model;
                isAuthenticated = true;
                this.Close();
            }
            else
            {
                Program.outputMessage += userResponseModel.OutputMessage;
            }
        }
Пример #5
0
        private void GetAccountTypes()
        {
            Encryptor encryptor = new Encryptor();

            StudentService.StudentServiceClient studentService = new StudentService.StudentServiceClient();

            ResponseModel <List <KeyValuePair <int, string> > > responseModel = encryptor.ResponseDeserializer <List <KeyValuePair <int, string> > >
                                                                                    (studentService.GetAccountTypes());

            if (responseModel.IsSuccess)
            {
                accountTypeComboBox.ValueMember   = "Key";
                accountTypeComboBox.DisplayMember = "Value";
                accountTypeComboBox.DataSource    = responseModel.Model;
            }
            else
            {
                MessageBox.Show(responseModel.OutputMessage);
            }
        }
Пример #6
0
        private void SendInstructions()
        {
            Encryptor encryptor = new Encryptor();

            StudentService.StudentServiceClient studentService = new StudentService.StudentServiceClient();

            ResponseModel<string[]> resetPasswordResponseModel = encryptor.ResponseDeserializer<string[]>
              (studentService.ResetPassword(usernameTextBox.Text));

            if (resetPasswordResponseModel.IsSuccess)
            {
                Instructions instructionsWindow = new Instructions(resetPasswordResponseModel.Model[0], resetPasswordResponseModel.Model[1]);
                instructionsWindow.Show();

                usernameTextBox.ReadOnly = true;
                instructionsLabel.Visible = true;
                sendInstructionsButton.Visible = false;
            }
            else
            {
                MessageBox.Show(resetPasswordResponseModel.OutputMessage);
            }
        }
Пример #7
0
        private void CreateAccount()
        {
            Encryptor encryptor = new Encryptor();

            StudentService.StudentServiceClient studentService = new StudentService.StudentServiceClient();

            ResponseModel <string> responseModel = encryptor.ResponseDeserializer <string>
                                                       (studentService.SignUp(usernameTextBox.Text, passwordTextBox.Text, Convert.ToInt16(accountTypeComboBox.SelectedValue)));

            if (responseModel.IsSuccess)
            {
                DialogResult result = MessageBox.Show(responseModel.Model);

                if (result == DialogResult.OK)
                {
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show(responseModel.OutputMessage);
            }
        }