Class InvitationRepository
- Namespace
- Builvero.Infrastructure.Repositories
- Assembly
- Builvero.Infrastructure.dll
Repository implementation for invitation data access operations using Entity Framework Core.
public class InvitationRepository : IInvitationRepository
- Inheritance
-
InvitationRepository
- Implements
- Inherited Members
Remarks
Invitations are codes that allow users to register for the platform. Each invitation can have usage limits and expiration dates.
Constructors
InvitationRepository(ApplicationDbContext)
Initializes a new instance of the InvitationRepository class.
public InvitationRepository(ApplicationDbContext context)
Parameters
contextApplicationDbContextThe Entity Framework database context for data access.
Methods
CreateAsync(Invitation, CancellationToken)
Creates a new invitation in the database.
public Task<Invitation> CreateAsync(Invitation invitation, CancellationToken cancellationToken = default)
Parameters
invitationInvitationThe invitation entity to create.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<Invitation>
The created invitation entity with its generated ID.
GetAllAsync(int, int, CancellationToken)
Retrieves a paginated list of all invitations.
public Task<List<Invitation>> GetAllAsync(int page, int pageSize, CancellationToken cancellationToken = default)
Parameters
pageintThe page number (1-based) to retrieve.
pageSizeintThe number of invitations per page.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<List<Invitation>>
A paginated list of invitations with their creators loaded, ordered by creation date (newest first).
GetByCodeAsync(string, CancellationToken)
Retrieves an invitation by its unique code.
public Task<Invitation?> GetByCodeAsync(string code, CancellationToken cancellationToken = default)
Parameters
codestringThe invitation code to search for.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<Invitation>
The invitation with its creator loaded, or null if not found.
GetByIdAsync(Guid, CancellationToken)
Retrieves an invitation by its unique identifier.
public Task<Invitation?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default)
Parameters
idGuidThe unique identifier of the invitation to retrieve.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<Invitation>
The invitation with its creator loaded, or null if not found.
GetCountAsync(CancellationToken)
Gets the total count of invitations in the database.
public Task<int> GetCountAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
UpdateAsync(Invitation, CancellationToken)
Updates an existing invitation in the database.
public Task<Invitation> UpdateAsync(Invitation invitation, CancellationToken cancellationToken = default)
Parameters
invitationInvitationThe invitation entity to update.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<Invitation>
The updated invitation entity.