Replaces ITaskService/TaskService, completing the CQRS/mediator refactor. All 9 old service interfaces are now gone except IPermissionService, ITokenService, and IPasswordHasher, which stay plain injected services by design (see spec). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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);
|
|
}
|
|
}
|