Class VolunteerApplicationRepository
- Namespace
- Builvero.Infrastructure.Repositories
- Assembly
- Builvero.Infrastructure.dll
Repository implementation for volunteer application data access operations using Entity Framework Core.
public class VolunteerApplicationRepository : IVolunteerApplicationRepository
- Inheritance
-
VolunteerApplicationRepository
- Implements
- Inherited Members
Remarks
Volunteer applications represent user submissions for volunteer roles. Applications include applicant information, resume storage references, and status tracking.
Constructors
VolunteerApplicationRepository(ApplicationDbContext)
Initializes a new instance of the VolunteerApplicationRepository class.
public VolunteerApplicationRepository(ApplicationDbContext context)
Parameters
contextApplicationDbContextThe Entity Framework database context for data access.
Methods
CreateAsync(VolunteerApplication, CancellationToken)
Creates a new volunteer application in the database.
public Task<VolunteerApplication> CreateAsync(VolunteerApplication application, CancellationToken cancellationToken = default)
Parameters
applicationVolunteerApplicationThe volunteer application entity to create.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerApplication>
The created volunteer application entity with its generated ID and CreatedAtUtc timestamp set.
DeleteAsync(Guid, CancellationToken)
Deletes a volunteer application from the database.
public Task<bool> DeleteAsync(Guid id, CancellationToken cancellationToken = default)
Parameters
idGuidThe unique identifier of the application to delete.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
EmailExistsAsync(string, CancellationToken)
Checks if an email address already exists in the volunteer applications database.
public Task<bool> EmailExistsAsync(string email, CancellationToken cancellationToken = default)
Parameters
emailstringThe email address to check.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
Remarks
The email is normalized (trimmed and lowercased) before comparison to match the database storage format.
GetApplicationsAsync(int, int, Guid?, ApplicationStatus?, CancellationToken)
Retrieves a paginated list of volunteer applications with optional filtering.
public Task<List<VolunteerApplication>> GetApplicationsAsync(int page, int pageSize, Guid? roleId = null, ApplicationStatus? status = null, CancellationToken cancellationToken = default)
Parameters
pageintThe page number (1-based) to retrieve.
pageSizeintThe number of applications per page.
roleIdGuid?Optional role ID filter to retrieve applications for a specific role.
statusApplicationStatus?Optional application status filter.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<List<VolunteerApplication>>
A paginated list of applications with Role loaded, ordered by creation date (newest first).
GetApplicationsCountAsync(Guid?, ApplicationStatus?, CancellationToken)
Gets the total count of volunteer applications matching the specified filters.
public Task<int> GetApplicationsCountAsync(Guid? roleId = null, ApplicationStatus? status = null, CancellationToken cancellationToken = default)
Parameters
roleIdGuid?Optional role ID filter.
statusApplicationStatus?Optional application status filter.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
GetByIdAsync(Guid, CancellationToken)
Retrieves a volunteer application by its unique identifier.
public Task<VolunteerApplication?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default)
Parameters
idGuidThe unique identifier of the application to retrieve.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerApplication>
The application with Role loaded, or null if not found.
UpdateAsync(VolunteerApplication, CancellationToken)
Updates an existing volunteer application in the database.
public Task<VolunteerApplication> UpdateAsync(VolunteerApplication application, CancellationToken cancellationToken = default)
Parameters
applicationVolunteerApplicationThe volunteer application entity to update.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerApplication>
The updated volunteer application entity.