Пример #1
0
        public void IfPhoneNumberNotExistsAndCanAddInDb()
        {
            var    teacher     = new TeacherRegisterController();
            string PhoneNumber = "5555511133";
            bool   result      = teacher.CheckPhoneExists(PhoneNumber);

            Assert.IsFalse(result, "Teacher phonenumber not exists in database and can  add");
        }
Пример #2
0
        public void IfPhoneNumberExistsInDb()
        {
            var    teacher     = new TeacherRegisterController();
            string PhoneNumber = "5555511111";
            bool   result      = teacher.CheckPhoneExists(PhoneNumber);

            Assert.IsTrue(result, "Teacher phonenumber exists in database and can not  add");
        }
Пример #3
0
        //add  teacher in db and checks if info is correct
        void AddTeacherInDb()
        {
            //NAME
            try
            {
                teacherRegisterController.SetName(FullName);
                if (FullName.Split(' ').ToList().Count > 3)
                {
                    throw new Exception();
                }
                if (teacherRegisterController.TeacherNameExists(FullName))
                {
                    MessageBox.Show("Teacher already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Wrong Name Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // ADD BirthDate

            teacherRegisterController.AddBirthdate(Date);

            //Email
            if (teacherRegisterController.IsValidEmail(Email))
            {
                if (teacherRegisterController.CheckEmailExists(Email))
                {
                    teacherRegisterController.SetEmail(Email);
                }
                else
                {
                    MessageBox.Show("Email is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Email is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //ADD Phone
            if (teacherRegisterController.PhoneIsValid(PhoneNumber))
            {
                if (teacherRegisterController.CheckPhoneExists(PhoneNumber) == false)
                {
                    teacherRegisterController.SetPhone(PhoneNumber);
                }
                else
                {
                    MessageBox.Show("Phone number is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Phone number is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //ADD EGN
            if (teacherRegisterController.IsValidEGN(EGN))
            {
                if (teacherRegisterController.CheckEGNExists(EGN) == false)
                {
                    teacherRegisterController.SetEGN(EGN);
                }
                else
                {
                    MessageBox.Show("EGN is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("EGN is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                if (Subject.SelectedItem == null)
                {
                    MessageBox.Show("Please select a subject!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    teacherRegisterController.SetSubject(Subject.Text);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please select a subject!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            teacherRegisterController.CommitChanged();
            MessageBox.Show("Success!", "Operation Completed", MessageBoxButtons.OK);
        }