Files
mws.backend.dotnet/mws.application/Tasks/Queries/SearchTasks.cs
T
namdhandClaude Sonnet 5 4a1bd0a0f9 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>
2026-08-17 21:07:27 +07:00

18 lines
636 B
C#

using AutoMapper;
using MediatR;
using Mws.Application.Common;
namespace Mws.Application.Tasks;
public record SearchTasksQuery(Guid UserId, string Term) : IRequest<List<TaskDto>>;
public class SearchTasksHandler(IUnitOfWork uow, IMapper mapper) : IRequestHandler<SearchTasksQuery, List<TaskDto>>
{
public async Task<List<TaskDto>> Handle(SearchTasksQuery query, CancellationToken ct)
{
var projectIds = await uow.Projects.GetProjectIdsForUserAsync(query.UserId, ct);
var tasks = await uow.Tasks.SearchWithAssigneeAsync(projectIds, query.Term, 20, ct);
return mapper.Map<List<TaskDto>>(tasks);
}
}