Table of Contents

Class EmailVerificationCodeRepository

Namespace
Builvero.Infrastructure.Repositories
Assembly
Builvero.Infrastructure.dll

Repository implementation for email verification code data access operations using Entity Framework Core.

public class EmailVerificationCodeRepository : IEmailVerificationCodeRepository
Inheritance
EmailVerificationCodeRepository
Implements
Inherited Members

Remarks

Email verification codes are used to verify user email addresses during registration or email change. Codes are single-use and marked as used after verification.

Constructors

EmailVerificationCodeRepository(ApplicationDbContext)

Initializes a new instance of the EmailVerificationCodeRepository class.

public EmailVerificationCodeRepository(ApplicationDbContext context)

Parameters

context ApplicationDbContext

The Entity Framework database context for data access.

Methods

CreateAsync(EmailVerificationCode, CancellationToken)

Creates a new email verification code in the database.

public Task<EmailVerificationCode> CreateAsync(EmailVerificationCode code, CancellationToken cancellationToken = default)

Parameters

code EmailVerificationCode

The email verification code entity to create.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<EmailVerificationCode>

The created email verification code entity with its generated ID.

GetByEmailAndCodeAsync(string, string, CancellationToken)

Retrieves an unused email verification code by email and code value.

public Task<EmailVerificationCode?> GetByEmailAndCodeAsync(string email, string code, CancellationToken cancellationToken = default)

Parameters

email string

The email address associated with the verification code.

code string

The verification code value.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<EmailVerificationCode>

The verification code with User loaded if found and unused; otherwise, null.

MarkAsUsedAsync(Guid, CancellationToken)

Marks an email verification code as used.

public Task MarkAsUsedAsync(Guid id, CancellationToken cancellationToken = default)

Parameters

id Guid

The unique identifier of the verification code to mark as used.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Repository implementation for email verification code data access operations using Entity Framework Core.

Remarks

If the code is not found, no action is taken. This method is idempotent.