Exemple #1
0
        public void CourseForm_CreateCourse()
        {
            var controller = new UserFormController(_userServices, _courseServices);
            var success    = controller.SaveUser(student);

            Assert.IsTrue(success);
        }
Exemple #2
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            _user.Name    = this.nameTextBox.Text;
            _user.Surname = this.surnameTextBox.Text;
            _user.NationalIdentificationNumber = this.nationalIdentificationNumberTextBox.Text;
            _user.Email = this.emailTextBox.Text;

            var password = this.passwordTextBox.Text;

            if (password.Length > 0)
            {
                _user.PasswordHash = EncryptionService.EncryptSHA1(password);
            }

            if (_user.Email.Length == 0 || _user.Name.Length == 0 || _user.Surname.Length == 0 ||
                _user.NationalIdentificationNumber.Length == 0 ||
                (_user.PasswordHash == null || _user.PasswordHash.Length == 0))
            {
                MessageBox.Show("Nisu popunjena sva polja", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            var checkedCoursesIndices = this.coursesCheckedListBox.CheckedIndices;
            var checkedCourses        = new List <Course>();

            foreach (int courseIndex in checkedCoursesIndices)
            {
                var courseId = ((Course)this.coursesCheckedListBox.Items[courseIndex]).Id;
                checkedCourses.Add(_courses.First(x => x.Id == courseId));
            }

            if (_user is Student)
            {
                Student student = (Student)_user;
                student.StudentIdentificationNumber = this.studentIdentificationNumberTextBox.Text;
                student.CoursesEnrolledIn           = checkedCourses;
            }

            if (_user is Lecturer)
            {
                Lecturer lecturer = (Lecturer)_user;
                lecturer.CoursesInChargeOf = checkedCourses;
            }

            var success = _userFormController.SaveUser(_user);

            if (success)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("Pohrana nije uspjela.");
            }
        }
Exemple #3
0
        public void UserForm_CreateAndEditUser()
        {
            this.UserForm_CreateUser();

            var controller = new UserFormController(_userServices, _courseServices);

            var newName    = "Pero";
            var newSurname = "Djetlic";

            student.Name    = newName;
            student.Surname = newSurname;

            var editSuccess = controller.SaveUser(student);
            var editedUser  = _userRepository.GetByEmail(student.Email);

            Assert.IsTrue(editSuccess);
            Assert.AreEqual(newName, editedUser.Name);
            Assert.AreEqual(newSurname, editedUser.Surname);
        }