Beispiel #1
0
        public void AssignStudentToSchool(string studentId, string schoolName)
        {
            var student = _dependency.GetStudentById(studentId);

            if (student == null)
            {
                throw new ArgumentException("Student could not be found", studentId);
            }

            var school = _dependency.GetSchoolByName(schoolName);

            if (school == null)
            {
                throw new ArgumentException("School could not be found", schoolName);
            }

            CheckStudentAgeForSchool(school, student);

            if (!_dependency.AddStudentToSchool(school, student))
            {
                throw new Exception("The student could not be assigned, try again later");
            }
        }