Esempio n. 1
0
        public void AddStudentToCourse(int courseId, Student student)
        {
            var course = _courseRepository.GetCourse(courseId);

            if (course == default(CourseEntity))
            {
                throw new CourseNotFound();
            }

            if (course.Capacity == 0)
            {
                throw new CourseFull();
            }

            var existingStudent = _studentRepository.GetStudentByEmail(student.Email);

            if (existingStudent != default(StudentEntity))
            {
                throw new DuplicatedEmail();
            }

            var studentEntity = _mapper.Map <StudentEntity>(student);

            _courseRepository.AddStudent(courseId, studentEntity);
        }