| 123456789101112131415161718192021222324252627 |
- using Application.Abstractions.Messaging;
- using Application.Abstractions.Data;
- using SharedKernel.Storage;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Document.Delete
- {
- public sealed class Handler(IAppDbContext db, IEditorImageService editorImage) : ICommandHandler<Command>
- {
- public async Task Handle(Command request, CancellationToken ct)
- {
- if (request.IDs is null || request.IDs.Length == 0)
- {
- return;
- }
- var contents = await db.Document.Where(c => request.IDs.Contains(c.ID)).Select(c => c.Content).ToListAsync(ct);
- foreach (var content in contents)
- {
- await editorImage.CleanupByContentAsync(content, ct);
- }
- await db.Document.Where(c => request.IDs.Contains(c.ID)).ExecuteDeleteAsync(ct);
- }
- }
- }
|