StudyEnrollmentsController

Namespace: Backend.Controllers
Assembly: Backend.dll

Controller for managing the association between members and their specific academic studies. The StudyEnrollmentsController provides a set of endpoints to track when and how users are enrolled in various programs, maintaining a historical and current record of their academic status. This controller is crucial for verifying eligibility for student-specific activities and benefits within the system. It enforces strict authorization to ensure that enrollment data—which often contains sensitive academic timelines—is only accessible to the account owner or authorized administrators. By utilizing the IStudyEnrollmentService, the controller abstracts the complex logic of managing overlapping enrollments and status transitions.

[Route("[controller]")]
[ApiController]
[Authorize]
public class StudyEnrollmentsController : ControllerBase

Inheritance

object ← ControllerBase ← StudyEnrollmentsController


Constructors


StudyEnrollmentsController(IStudyEnrollmentService)

Controller for managing the association between members and their specific academic studies. The StudyEnrollmentsController provides a set of endpoints to track when and how users are enrolled in various programs, maintaining a historical and current record of their academic status. This controller is crucial for verifying eligibility for student-specific activities and benefits within the system. It enforces strict authorization to ensure that enrollment data—which often contains sensitive academic timelines—is only accessible to the account owner or authorized administrators. By utilizing the IStudyEnrollmentService, the controller abstracts the complex logic of managing overlapping enrollments and status transitions.

public StudyEnrollmentsController(IStudyEnrollmentService studyEnrollmentService)

Parameters

NameTypeDescription
studyEnrollmentServiceIStudyEnrollmentServiceThe study enrollment service responsible for study enrollment business logic and data persistence.

Methods


DeleteStudyEnrollment(uint, CancellationToken)

Permanently removes a study enrollment record from the system. The DeleteStudyEnrollment endpoint allows for the removal of incorrectly entered or obsolete enrollment data. This operation is strictly guarded to prevent accidental loss of academic history and requires the requester to have administrative rights or ownership of the record. Following successful deletion, a 204 No Content status is returned to the client.

[HttpDelete("{id}")]
[Produces("application/json", new string[] { })]
[Consumes("application/json", new string[] { })]
[ProducesResponseType(204)]
[ProducesResponseType(404)]
[ProducesResponseType(403)]
[ProducesResponseType(typeof(ErrorResponseDto), 400)]
[ProducesResponseType(typeof(ErrorResponseDto), 500)]
public Task<ActionResult> DeleteStudyEnrollment(uint id, CancellationToken ct)

Parameters

NameTypeDescription
iduintThe unique identifier of the study enrollment to delete.
ctCancellationTokenThe cancellation token to monitor for request cancellation.

Returns

TypeDescription
Task<ActionResult>A 204 No Content status upon successful deletion.

GetStudyEnrollment(uint, CancellationToken)

Retrieves the details of a specific study enrollment by its unique identifier. The GetStudyEnrollment endpoint provides a comprehensive view of a single enrollment record, including the associated study details, start/end dates, and the current status of the enrollment. This granular access is necessary for verifying specific academic claims or troubleshooting individual member profiles. If the enrollment record is not found or access is denied, the endpoint returns the appropriate HTTP status code.

[HttpGet("{id}")]
[Produces("application/json", new string[] { })]
[ProducesResponseType(typeof(StudyEnrollmentResponseDTO), 200)]
[ProducesResponseType(403)]
[ProducesResponseType(404)]
[ProducesResponseType(typeof(ErrorResponseDto), 400)]
[ProducesResponseType(typeof(ErrorResponseDto), 500)]
public Task<ActionResult<StudyEnrollmentResponseDTO>> GetStudyEnrollment(uint id, CancellationToken ct)

Parameters

NameTypeDescription
iduintThe unique identifier of the study enrollment to retrieve.
ctCancellationTokenThe cancellation token to monitor for request cancellation.

Returns

TypeDescription
Task<ActionResult, StudyEnrollmentResponseDTO>The detailed study enrollment record if found; otherwise, a 404 status.

GetStudyEnrollments(GetStudyEnrollmentsDTO, CancellationToken)

Retrieves a list of study enrollments based on the provided query parameters. The GetStudyEnrollments endpoint allows authorized users to fetch enrollment records, which can be filtered and paginated via the GetStudyEnrollmentsDTO. This is primarily used by administrators to oversee student demographics or by individual users to view their own academic history within the system. The endpoint ensures that the returned data is scoped according to the requester's permissions, preventing unauthorized access to other members' academic records.

[HttpGet]
[Produces("application/json", new string[] { })]
[ProducesResponseType(typeof(IEnumerable<StudyEnrollmentResponseDTO>), 200)]
[ProducesResponseType(403)]
[ProducesResponseType(typeof(ErrorResponseDto), 400)]
[ProducesResponseType(typeof(ErrorResponseDto), 500)]
public Task<ActionResult<IEnumerable<StudyEnrollmentResponseDTO>>> GetStudyEnrollments(GetStudyEnrollmentsDTO dto, CancellationToken ct)

Parameters

NameTypeDescription
dtoGetStudyEnrollmentsDTOThe data transfer object containing filtering and pagination criteria.
ctCancellationTokenThe cancellation token to monitor for request cancellation.

Returns

TypeDescription
Task<ActionResult, IEnumerable, StudyEnrollmentResponseDTO>A collection of study enrollment response objects matching the criteria.

PatchStudy(uint, JsonPatchDocument<StudyEnrollment>, CancellationToken)

Partially updates an existing study enrollment using a JSON Patch document. The PatchStudy endpoint (targeting a specific StudyEnrollment) allows for the modification of specific enrollment attributes—such as adjusting a graduation date or changing a status—without the need to resend the entire record. This ensures that updates are targeted and efficient. The endpoint validates the proposed changes against the enrollment domain rules and verifies the user's authority to modify the record before persisting the changes.

[HttpPatch("{id}")]
[Consumes("application/json", new string[] { })]
[Produces("application/json", new string[] { })]
[ProducesResponseType(204)]
[ProducesResponseType(404)]
[ProducesResponseType(403)]
[ProducesResponseType(typeof(ErrorResponseDto), 400)]
[ProducesResponseType(typeof(ErrorResponseDto), 500)]
public Task<ActionResult> PatchStudy(uint id, JsonPatchDocument<StudyEnrollment> patchDoc, CancellationToken ct)

Parameters

NameTypeDescription
iduintThe unique identifier of the study enrollment to update.
patchDocJsonPatchDocument<StudyEnrollment>The JSON Patch document containing the intended modifications.
ctCancellationTokenThe cancellation token to monitor for request cancellation.

Returns

TypeDescription
Task<ActionResult>A 204 No Content status if the patch was successfully applied.

PostStudyEnrollment(PostStudyEnrollmentDTO, CancellationToken)

Creates a new study enrollment record for a member. The PostStudyEnrollment endpoint processes requests to link a member to a specific academic study using the PostStudyEnrollmentDTO. This operation involves validating the enrollment period and ensuring the member is not already enrolled in a conflicting program. The endpoint enforces authorization to ensure that users can only create enrollments for themselves or, in the case of staff, for other members. Upon success, it returns the newly created enrollment details.

[HttpPost]
[Consumes("application/json", new string[] { })]
[Produces("application/json", new string[] { })]
[ProducesResponseType(typeof(StudyEnrollmentResponseDTO), 201)]
[ProducesResponseType(403)]
[ProducesResponseType(typeof(ErrorResponseDto), 400)]
[ProducesResponseType(typeof(ErrorResponseDto), 500)]
public Task<ActionResult<StudyEnrollmentResponseDTO>> PostStudyEnrollment(PostStudyEnrollmentDTO dto, CancellationToken ct)

Parameters

NameTypeDescription
dtoPostStudyEnrollmentDTOThe data transfer object containing the new enrollment configuration.
ctCancellationTokenThe cancellation token to monitor for request cancellation.

Returns

TypeDescription
Task<ActionResult, StudyEnrollmentResponseDTO>The newly created study enrollment response object with a 201 Created status.

On this page