| | | 1 | | namespace Syki.Back.Features.Students.EnrollStudentInCourseOffering; |
| | | 2 | | |
| | | 3 | | [ApiController, Authorize(Policies.EnrollStudentInCourseOffering)] |
| | 0 | 4 | | public class EnrollStudentInCourseOfferingController(EnrollStudentInCourseOfferingService service) : ControllerBase |
| | | 5 | | { |
| | | 6 | | /// <summary>Matricular aluno em oferta de curso</summary> |
| | | 7 | | /// <remarks>Vincula um aluno a uma oferta de curso, criando uma matrícula.</remarks> |
| | | 8 | | [HttpPost("students/{studentId:int}/course-offerings")] |
| | | 9 | | [SwaggerResponseExample(200, typeof(ResponseExamples))] |
| | | 10 | | [SwaggerResponseExample(400, typeof(ErrorsExamples))] |
| | | 11 | | public async Task<IActionResult> Enroll([FromRoute] int studentId, [FromBody] EnrollStudentInCourseOfferingIn data) |
| | | 12 | | { |
| | 0 | 13 | | var result = await service.Enroll(studentId, data); |
| | 0 | 14 | | return result.Match<IActionResult>(Ok, BadRequest); |
| | 0 | 15 | | } |
| | | 16 | | } |
| | | 17 | | |
| | | 18 | | internal class RequestExamples : ExamplesProvider<EnrollStudentInCourseOfferingIn>; |
| | | 19 | | internal class ResponseExamples : ExamplesProvider<EnrollStudentInCourseOfferingOut>; |
| | | 20 | | internal class ErrorsExamples : ErrorExamplesProvider< |
| | | 21 | | StudentNotFound, |
| | | 22 | | CourseOfferingNotFound, |
| | | 23 | | StudentAlreadyEnrolledInCourseOffering |
| | | 24 | | >; |