| 1234567891011121314151617181920212223242526272829303132 |
- using Application.Abstractions.Data;
- using Application.Abstractions.Messaging;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Forum.CommentReport.UpdateStatus;
- 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 reports = await db.CommentReport.Where(c => request.IDs.Contains(c.ID)).ToListAsync(ct);
- foreach (var report in reports)
- {
- report.Status = request.Status;
- if (request.Memo is not null)
- {
- report.Memo = request.Memo;
- }
- report.UpdatedAt = DateTime.UtcNow;
- }
- await db.SaveChangesAsync(ct);
- }
- }
|