| 123456789101112131415161718192021222324252627282930 |
- using Application.Abstractions.Data;
- using Application.Abstractions.Messaging;
- using Domain.Entities.Common.ValueObject;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Admin.Mail.Resend;
- public sealed class Handler(IAppDbContext db) : ICommandHandler<Command>
- {
- public async Task Handle(Command request, CancellationToken ct)
- {
- if (request.IDs is null || request.IDs.Length == 0)
- {
- return;
- }
- var now = DateTime.UtcNow;
- // Status를 Pending 으로 되돌리고, RetryCount 리셋, NextRetryAt 즉시 처리되도록 설정
- await db.EmailLog
- .Where(x => request.IDs.Contains(x.ID))
- .ExecuteUpdateAsync(s => s
- .SetProperty(x => x.Status, MailStatus.Pending)
- .SetProperty(x => x.RetryCount, 0)
- .SetProperty(x => x.NextRetryAt, now)
- .SetProperty(x => x.LastError, (string?)null)
- .SetProperty(x => x.ProcessedAt, (DateTime?)null)
- .SetProperty(x => x.FailedAt, (DateTime?)null), ct);
- }
- }
|