using System.Threading;
using Dpz.Core.Public.ViewModel.RequestEvent;
namespace Dpz.Core.Service.Event;
public class RemoveImagesEvent(IRepository<WaitExecution> repository) : IRequestHandler<RemoveImagesRequest>
{
public async Task Handle(RemoveImagesRequest request, CancellationToken cancellationToken)
{
var images = request.Images ?? [];
var imageTasks = images
.Select(x => new WaitExecution
{
Category = ExecuteCategory.Delete,
Relation = x,
Scheme = ExecuteScheme.DeleteUpyun,
Status = ExecuteStatus.NotExecute,
CreateTime = DateTime.Now,
LastUpdateTime = null
})
.ToList();
if (imageTasks.Count > 0)
await repository.InsertAsync(imageTasks);
}
}