Class AdminVolunteerController
- Namespace
- Builvero.Api.Controllers
- Assembly
- Builvero.Api.dll
Provides administrative API endpoints for managing volunteer roles and applications.
[ApiController]
[Route("api/admin/volunteer")]
[Authorize(Policy = "AdminRead")]
public class AdminVolunteerController : ControllerBase
- Inheritance
-
AdminVolunteerController
- Inherited Members
Remarks
This controller requires authorization via the "AdminRead" policy for read operations and "AdminWrite" policy for write operations.
All endpoints are prefixed with /api/admin/volunteer.
The controller handles:
- Retrieving all volunteer roles (including inactive)
- Opening and closing volunteer roles (activating/deactivating)
- Retrieving volunteer applications with pagination and filtering
- Retrieving application details and resume download URLs
- Updating application status (New, Reviewed, Accepted)
- Deleting applications (GDPR compliance - right to be forgotten)
Resume files are stored in S3 and accessed via presigned URLs. Application deletion permanently removes the application from the database and the resume from S3 storage.
Constructors
AdminVolunteerController(IVolunteerRoleService, IVolunteerApplicationService, ILogger<AdminVolunteerController>)
Initializes a new instance of the AdminVolunteerController class.
public AdminVolunteerController(IVolunteerRoleService roleService, IVolunteerApplicationService applicationService, ILogger<AdminVolunteerController> logger)
Parameters
roleServiceIVolunteerRoleServiceService for volunteer role operations.
applicationServiceIVolunteerApplicationServiceService for volunteer application operations.
loggerILogger<AdminVolunteerController>Logger for recording operations and errors.
Methods
CloseRole(Guid, CancellationToken)
Closes a volunteer role by setting IsActive to false.
[HttpPost("roles/{id}/close")]
[Authorize(Policy = "AdminWrite")]
public Task<ActionResult<VolunteerRoleDto>> CloseRole(Guid id, CancellationToken cancellationToken)
Parameters
idGuidThe unique identifier of the volunteer role to close.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<VolunteerRoleDto>>
200 OK: Returns updated VolunteerRoleDto with IsActive set to false
400 Bad Request: Role not found or error closing role
Remarks
Requires AdminWrite policy. Closes the volunteer role, making it inactive and preventing new applications. Existing applications remain accessible. The role can be reopened using the OpenRole endpoint.
DiscardApplication(Guid, CancellationToken)
Permanently deletes a volunteer application and its associated resume file (GDPR compliance - right to be forgotten).
[HttpDelete("applications/{id}")]
[Authorize(Policy = "AdminWrite")]
public Task<ActionResult> DiscardApplication(Guid id, CancellationToken cancellationToken)
Parameters
idGuidThe unique identifier of the application to delete.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult>
204 No Content: Application and resume successfully deleted
404 Not Found: Application not found
500 Internal Server Error: Error deleting application or resume
Remarks
Requires AdminWrite policy. Permanently removes the application from the database and the resume file from S3 storage. This operation cannot be undone. Used for GDPR compliance when a user requests their data to be deleted.
GetApplication(Guid, CancellationToken)
Retrieves detailed information for a specific volunteer application.
[HttpGet("applications/{id}")]
public Task<ActionResult<VolunteerApplicationDto>> GetApplication(Guid id, CancellationToken cancellationToken)
Parameters
idGuidThe unique identifier of the application to retrieve.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<VolunteerApplicationDto>>
200 OK: Returns VolunteerApplicationDto with complete application information
404 Not Found: Application not found
500 Internal Server Error: Error retrieving application
Remarks
Requires AdminRead policy. Returns complete application details including personal information, resume information, and application status. Used by admin interfaces to review applications.
GetApplications(int, int, Guid?, string?, CancellationToken)
Retrieves volunteer applications with pagination and optional filtering by role and status.
[HttpGet("applications")]
public Task<ActionResult<object>> GetApplications(int page = 1, int pageSize = 20, Guid? roleId = null, string? status = null, CancellationToken cancellationToken = default)
Parameters
pageintThe page number (1-based). Defaults to 1.
pageSizeintThe number of applications per page. Defaults to 20.
roleIdGuid?Optional filter by volunteer role ID.
statusstringOptional filter by application status (New, Reviewed, Accepted). Case-insensitive.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<object>>
200 OK: Returns
{ "applications": [...], "totalCount": int, "page": int, "pageSize": int }500 Internal Server Error: Error retrieving applications
Remarks
Requires AdminRead policy. Returns paginated list of volunteer applications. Supports filtering by role ID and status. Applications are ordered by creation date (newest first).
GetResumeDownloadUrl(Guid, CancellationToken)
Generates a presigned URL for downloading a volunteer application's resume file.
[HttpGet("applications/{id}/resume-download")]
public Task<ActionResult<object>> GetResumeDownloadUrl(Guid id, CancellationToken cancellationToken)
Parameters
idGuidThe unique identifier of the application whose resume to download.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<object>>
200 OK: Returns
{ "downloadUrl": "presigned-url" }with a presigned S3 URL (15-minute expiration)400 Bad Request: Application not found, resume not available, or error generating URL
Remarks
Requires AdminRead policy. Generates a presigned S3 URL that allows secure, temporary access to the resume file. The URL expires after 15 minutes. Resume files are stored in S3 under the resumes/ prefix.
GetRoles(CancellationToken)
Retrieves all volunteer roles in the system, including inactive roles.
[HttpGet("roles")]
public Task<ActionResult<List<VolunteerRoleDto>>> GetRoles(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<List<VolunteerRoleDto>>>
200 OK: Returns list of VolunteerRoleDto objects
500 Internal Server Error: Error retrieving roles
Remarks
Requires AdminRead policy. Returns all volunteer roles regardless of their active status. Used by admin interfaces to manage available volunteer positions.
OpenRole(Guid, CancellationToken)
Opens a volunteer role by setting IsActive to true.
[HttpPost("roles/{id}/open")]
[Authorize(Policy = "AdminWrite")]
public Task<ActionResult<VolunteerRoleDto>> OpenRole(Guid id, CancellationToken cancellationToken)
Parameters
idGuidThe unique identifier of the volunteer role to open.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<VolunteerRoleDto>>
200 OK: Returns updated VolunteerRoleDto with IsActive set to true
400 Bad Request: Role not found or error opening role
Remarks
Requires AdminWrite policy. Opens the volunteer role, making it active and allowing new applications. The role becomes visible in public volunteer role listings.
UpdateApplicationStatus(Guid, UpdateApplicationStatusRequest, CancellationToken)
Updates the status of a volunteer application.
[HttpPatch("applications/{id}/status")]
[Authorize(Policy = "AdminWrite")]
public Task<ActionResult<VolunteerApplicationDto>> UpdateApplicationStatus(Guid id, UpdateApplicationStatusRequest request, CancellationToken cancellationToken)
Parameters
idGuidThe unique identifier of the application to update.
requestUpdateApplicationStatusRequestThe update request containing the new status (New, Reviewed, Accepted).
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<VolunteerApplicationDto>>
200 OK: Returns updated VolunteerApplicationDto with new status
400 Bad Request: Invalid status value, application not found, or error updating status
Remarks
Requires AdminWrite policy. Updates the application status to one of: New, Reviewed, or Accepted. Status values are case-insensitive. Used by admins to track application review progress.