Страница профиля
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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<SearchCompetenciesQuery, List<string>>
|
||||
{
|
||||
private readonly IdentityDbContext _context;
|
||||
|
||||
public SearchCompetenciesQueryHandler(IdentityDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<List<string>> Handle(SearchCompetenciesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(request.Query))
|
||||
return new List<string>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user