using MediatR; using Microsoft.EntityFrameworkCore; using Nashel.Modules.Identity.Application.Queries; using Nashel.Modules.Identity.Infrastructure.Persistence; namespace Nashel.Modules.Identity.Infrastructure.QueryHandlers; public class SearchCompetenciesQueryHandler : IRequestHandler> { private readonly IdentityDbContext _context; public SearchCompetenciesQueryHandler(IdentityDbContext context) { _context = context; } public async Task> Handle(SearchCompetenciesQuery request, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(request.Query)) return new List(); var query = request.Query.ToLower(); var competencies = await _context.Competencies .Where(c => c.Name.ToLower().Contains(query)) .Select(c => c.Name) .Take(10) // Ограничиваем результаты .ToListAsync(cancellationToken); return competencies; } }