Table of Contents

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

context ApplicationDbContext

The 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

application VolunteerApplication

The volunteer application entity to create.

cancellationToken CancellationToken

Cancellation 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

id Guid

The unique identifier of the application to delete.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<bool>

True if the application was successfully deleted; false if it was not found.

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

email string

The email address to check.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<bool>

True if an application with the email address exists; otherwise, false.

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

page int

The page number (1-based) to retrieve.

pageSize int

The number of applications per page.

roleId Guid?

Optional role ID filter to retrieve applications for a specific role.

status ApplicationStatus?

Optional application status filter.

cancellationToken CancellationToken

Cancellation 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

roleId Guid?

Optional role ID filter.

status ApplicationStatus?

Optional application status filter.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<int>

The total count of applications matching the filters.

GetByIdAsync(Guid, CancellationToken)

Retrieves a volunteer application by its unique identifier.

public Task<VolunteerApplication?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default)

Parameters

id Guid

The unique identifier of the application to retrieve.

cancellationToken CancellationToken

Cancellation 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

application VolunteerApplication

The volunteer application entity to update.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<VolunteerApplication>

The updated volunteer application entity.