Beispiel #1
0
        private void SubmitData(object sender, EventArgs e)
        {
            //User usersz = StudentRepository.GetStudentById(1).User;
            if (FormValidationCheck().ValidationStatus)
            {
                User user = new User();
                user.Name        = textBoxName.Text;
                user.Address     = textBoxAddress.Text;
                user.PhoneNumber = textBoxPhone.Text;
                user.UserName    = textBoxEmail.Text;
                user.Password    = textBoxPassword.Text;
                user.UserEnabled = true;
                if (profileImagePictureBox.Image != null)
                {
                    user.UserAvatar = SaveImage(profileImagePictureBox.ImageLocation);
                }
                UserRepository.AddUser(user);
                if (checkBoxTeacher.Checked)
                {
                    Teacher teacher = new Teacher();
                    teacher.UserId          = user.UserId;
                    teacher.AvailableToHire = radioButtonAvailable.Checked ? true : false;
                    teacher.ChargeAmount    = Convert.ToDecimal(textBoxSetCharge.Text);
                    TeacherRepository.AddTeacher(teacher);

                    foreach (Skill skill in skills)
                    {
                        skill.TeacherId = teacher.TeacherId;
                    }
                    SkillRepository.AddSkills(skills);
                }
                else
                {
                    Student student = new Student();
                    student.UserId = user.UserId;
                    StudentRepository.AddStudent(student);
                }
                MessageBox.Show("Registration Successful !", "Success !");
                int milliseconds = 1000;
                Thread.Sleep(milliseconds);
                this.Hide();
                new LogIn().Show();
            }
            else
            {
                MessageBox.Show(FormValidationCheck().Errors, "Error");
            }
        }