2026-08-17 21:06:40 +07:00
|
|
|
using MediatR;
|
2026-08-19 23:25:08 +07:00
|
|
|
using mws.backend.dotnet.application.Common;
|
2026-08-17 21:06:40 +07:00
|
|
|
|
2026-08-19 23:25:08 +07:00
|
|
|
namespace mws.backend.dotnet.application.Tasks;
|
2026-08-17 21:06:40 +07:00
|
|
|
|
|
|
|
|
public record DeleteTaskCommand(Guid UserId, Guid TaskId) : IRequest;
|
|
|
|
|
|
|
|
|
|
public class DeleteTaskHandler(IUnitOfWork uow) : IRequestHandler<DeleteTaskCommand>
|
|
|
|
|
{
|
|
|
|
|
public async Task Handle(DeleteTaskCommand command, CancellationToken ct)
|
|
|
|
|
{
|
|
|
|
|
var task = await TaskAccess.GetTaskForUserAsync(uow, command.UserId, command.TaskId, ct);
|
|
|
|
|
uow.Tasks.Remove(task);
|
|
|
|
|
await uow.SaveChangesAsync(ct);
|
|
|
|
|
}
|
|
|
|
|
}
|