-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathClientFinder.cs
More file actions
45 lines (40 loc) · 1.37 KB
/
ClientFinder.cs
File metadata and controls
45 lines (40 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
namespace Volo.Abp.IdentityServer.Clients;
public class ClientFinder: IClientFinder, ITransientDependency
{
protected IClientRepository ClientRepository { get; }
public ClientFinder(IClientRepository clientRepository)
{
ClientRepository = clientRepository;
}
public virtual async Task<List<ClientFinderResult>> SearchAsync(string filter, int page = 1)
{
using (ClientRepository.DisableTracking())
{
page = page < 1 ? 1 : page;
var clients = await ClientRepository.GetListAsync(nameof(Client.ClientName), filter: filter, skipCount: (page - 1) * 10, maxResultCount: 10);
return clients.Select(x => new ClientFinderResult
{
Id = x.Id,
ClientId = x.ClientId
}).ToList();
}
}
public virtual async Task<List<ClientFinderResult>> SearchByIdsAsync(Guid[] ids)
{
using (ClientRepository.DisableTracking())
{
var clients = await ClientRepository.GetListByIdsAsync(ids);
return clients.Select(x => new ClientFinderResult
{
Id = x.Id,
ClientId = x.ClientId
}).ToList();
}
}
}