using Application.Abstractions.Data; using Application.Abstractions.Messaging; using Microsoft.EntityFrameworkCore; namespace Application.Features.Admin.Forum.Trash.Post.Restore; public sealed class Handler(IAppDbContext db) : ICommandHandler { public async Task Handle(Command request, CancellationToken ct) { if (request.IDs is null || request.IDs.Length == 0) { return; } var posts = await db.Post.Where(c => request.IDs.Contains(c.ID) && c.IsDeleted).ToListAsync(ct); foreach (var post in posts) { post.IsDeleted = false; post.DeletedAt = null; post.UpdatedAt = DateTime.UtcNow; } await db.SaveChangesAsync(ct); } }