Compare commits
2 Commits
d1bb921b4b
...
0d9c3d46ca
| Author | SHA1 | Date |
|---|---|---|
|
|
0d9c3d46ca | |
|
|
81c9f89214 |
|
|
@ -10,6 +10,11 @@ public class Student
|
|||
public string Name { get; private set; } = string.Empty;
|
||||
public Email Email { get; private set; } = null!;
|
||||
|
||||
// Activation fields
|
||||
public string? ActivationCodeHash { get; private set; }
|
||||
public DateTime? ActivationExpiresAt { get; private set; }
|
||||
public bool IsActivated => ActivationCodeHash == null;
|
||||
|
||||
private readonly List<Enrollment> _enrollments = [];
|
||||
public IReadOnlyCollection<Enrollment> Enrollments => _enrollments.AsReadOnly();
|
||||
|
||||
|
|
@ -53,4 +58,19 @@ public class Student
|
|||
{
|
||||
_enrollments.Remove(enrollment);
|
||||
}
|
||||
|
||||
public void SetActivationCode(string codeHash, TimeSpan expiresIn)
|
||||
{
|
||||
ActivationCodeHash = codeHash;
|
||||
ActivationExpiresAt = DateTime.UtcNow.Add(expiresIn);
|
||||
}
|
||||
|
||||
public void ClearActivationCode()
|
||||
{
|
||||
ActivationCodeHash = null;
|
||||
ActivationExpiresAt = null;
|
||||
}
|
||||
|
||||
public bool IsActivationExpired() =>
|
||||
ActivationExpiresAt.HasValue && DateTime.UtcNow > ActivationExpiresAt.Value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ public interface IStudentRepository
|
|||
int pageSize = 10,
|
||||
CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all students with pending activation (not expired).
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<Student>> GetPendingActivationAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new student to the context.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue