17 lines
500 B
C#
17 lines
500 B
C#
using MediatR;
|
|||
|
|
using Mws.Application.Common;
|
||
|
|
|
||
|
|
namespace Mws.Application.Tasks;
|
||
|
|
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
}
|