using AutoMapper; using MediatR; using Mws.Application.Common; using Mws.Application.Permissions; namespace Mws.Application.Accounts; public record GetAccountsQuery(Guid ActorUserId, string? Term) : IRequest>; public class GetAccountsHandler(IUnitOfWork uow, IPermissionService permissions, IMapper mapper) : IRequestHandler> { private const string Screen = "accounts"; public async Task> Handle(GetAccountsQuery query, CancellationToken ct) { await permissions.EnsureAsync(query.ActorUserId, Screen, PermissionAction.View, ct); var users = await uow.Users.SearchWithRoleAsync(query.Term, null, ct); return mapper.Map>(users); } }