Class VolunteerRoleRepository
- Namespace
- Builvero.Infrastructure.Repositories
- Assembly
- Builvero.Infrastructure.dll
Repository implementation for volunteer role data access operations using Entity Framework Core.
public class VolunteerRoleRepository : IVolunteerRoleRepository
- Inheritance
-
VolunteerRoleRepository
- Implements
- Inherited Members
Remarks
Volunteer roles represent open positions that users can apply for. Roles can be active (visible to applicants) or inactive (hidden from public view).
Constructors
VolunteerRoleRepository(ApplicationDbContext)
Initializes a new instance of the VolunteerRoleRepository class.
public VolunteerRoleRepository(ApplicationDbContext context)
Parameters
contextApplicationDbContextThe Entity Framework database context for data access.
Methods
CreateAsync(VolunteerRole, CancellationToken)
Creates a new volunteer role in the database.
public Task<VolunteerRole> CreateAsync(VolunteerRole role, CancellationToken cancellationToken = default)
Parameters
roleVolunteerRoleThe volunteer role entity to create.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerRole>
The created volunteer role entity with its generated ID and timestamps set.
GetActiveRolesAsync(CancellationToken)
Retrieves all active volunteer roles (visible to applicants).
public Task<List<VolunteerRole>> GetActiveRolesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<List<VolunteerRole>>
A list of active roles, ordered alphabetically by title.
GetAllRolesAsync(CancellationToken)
Retrieves all volunteer roles including inactive ones (for admin purposes).
public Task<List<VolunteerRole>> GetAllRolesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<List<VolunteerRole>>
A list of all roles, ordered alphabetically by title.
GetByIdAsync(Guid, CancellationToken)
Retrieves a volunteer role by its unique identifier.
public Task<VolunteerRole?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default)
Parameters
idGuidThe unique identifier of the role to retrieve.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerRole>
The role with Applications loaded, or null if not found.
GetByKeyAsync(string, CancellationToken)
Retrieves a volunteer role by its unique key.
public Task<VolunteerRole?> GetByKeyAsync(string key, CancellationToken cancellationToken = default)
Parameters
keystringThe unique key of the role to retrieve.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerRole>
The role if found; otherwise, null.
UpdateAsync(VolunteerRole, CancellationToken)
Updates an existing volunteer role in the database.
public Task<VolunteerRole> UpdateAsync(VolunteerRole role, CancellationToken cancellationToken = default)
Parameters
roleVolunteerRoleThe volunteer role entity to update.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<VolunteerRole>
The updated volunteer role entity with UpdatedAtUtc timestamp set.