Convert Tasks module to MediatR commands/queries

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>
This commit is contained in:
2026-08-17 21:07:27 +07:00
co-authored by Claude Sonnet 5
parent c3384d76d9
commit 4a1bd0a0f9
11 changed files with 200 additions and 154 deletions
+35
View File
@@ -0,0 +1,35 @@
using AutoMapper;
using Mws.Application.Common;
using Mws.Domain.Tasks;
namespace Mws.Application.Tasks;
internal static class TaskAccess
{
public static async Task<TaskDto> GetDtoAsync(IUnitOfWork uow, IMapper mapper, Guid id, CancellationToken ct)
{
var task = await uow.Tasks.GetWithAssigneeAsync(id, ct)
?? throw new NotFoundException("Task not found");
return mapper.Map<TaskDto>(task);
}
public static async Task<TaskItem> GetTaskForUserAsync(IUnitOfWork uow, Guid userId, Guid taskId, CancellationToken ct)
{
var task = await uow.Tasks.GetByIdAsync(taskId, ct)
?? throw new NotFoundException("Task not found");
if (!await uow.Projects.IsMemberAsync(task.ProjectId, userId, ct))
{
throw new NotFoundException("Task not found");
}
return task;
}
public static async Task EnsureMemberAccessAsync(IUnitOfWork uow, Guid userId, Guid projectId, CancellationToken ct)
{
if (!await uow.Projects.IsMemberAsync(projectId, userId, ct))
{
throw new NotFoundException("Project not found");
}
}
}