コード例 #1
0
        public IActionResult Enroll(long id, EnrollRequest request)
        {
            Student student = _studentRepository.GetById(id);

            if (student == null)
            {
                return(Error(Errors.General.NotFound(), nameof(id)));
            }

            (string Course, string Grade)[] input = request.Enrollments
コード例 #2
0
        public IActionResult Enroll(long id, [FromBody] EnrollRequest request)
        {
            Student student = _studentRepository.GetById(id);

            foreach (CourseEnrollmentDto enrollmentDto in request.Enrollments)
            {
                Course course = _courseRepository.GetByName(enrollmentDto.Course);
                var    grade  = Enum.Parse <Grade>(enrollmentDto.Grade);

                student.Enroll(course, grade);
            }

            return(Ok());
        }