private static SearchClientParameter ToParameter(IEnumerable <KeyValuePair <string, string> > queries) { var result = new SearchClientParameter(); result.ExtractSearchParameter(queries); return(result); }
public Task <SearchResult <OAuthClient> > Find(SearchClientParameter parameter, CancellationToken token) { var result = _clients.AsQueryable(); if (!string.IsNullOrWhiteSpace(parameter.RegistrationAccessToken)) { result = result.Where(_ => _.RegistrationAccessToken == parameter.RegistrationAccessToken); } if (MAPPING_CLIENT_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_CLIENT_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = result.Count(); result = result.Skip(parameter.StartIndex).Take(parameter.Count); return(Task.FromResult(new SearchResult <OAuthClient> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = result.ToList().Cast <OAuthClient>().ToList() })); }
public async Task <SearchResult <BaseClient> > Find(SearchClientParameter parameter, CancellationToken token) { IQueryable <OAuthClient> result = GetClients(); if (!string.IsNullOrWhiteSpace(parameter.RegistrationAccessToken)) { result = result.Where(c => c.RegistrationAccessToken == parameter.RegistrationAccessToken); } if (MAPPING_CLIENT_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_CLIENT_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = await result.CountAsync(token); result = result.Skip(parameter.StartIndex).Take(parameter.Count); ICollection <BaseClient> content = (await result.ToListAsync(token)).Cast <BaseClient>().ToList(); return(new SearchResult <BaseClient> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = content }); }
public Task <SearchClientResult> Execute(SearchClientParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } return(_clientRepository.Search(parameter)); }
public async Task <JObject> Handle(SearchClientParameter parameter, string issuer, CancellationToken cancellationToken) { var result = await _oauthClientRepository.Find(parameter, cancellationToken); return(new JObject { { "start_index", result.StartIndex }, { "count", result.Count }, { "total_length", result.TotalLength }, { "content", new JArray(result.Content.Select(c => ToDto(c, issuer))) } }); }
public Task <SearchClientResult> Search(SearchClientParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } IEnumerable <Common.Models.Client> result = _clients; if (parameter.ClientIds != null && parameter.ClientIds.Any()) { result = result.Where(c => parameter.ClientIds.Any(i => c.ClientId.Contains(i))); } if (parameter.ClientNames != null && parameter.ClientNames.Any()) { result = result.Where(c => parameter.ClientNames.Any(n => c.ClientName.Contains(n))); } if (parameter.ClientTypes != null && parameter.ClientTypes.Any()) { var clientTypes = parameter.ClientTypes.Select(t => (Common.Models.ApplicationTypes)t); result = result.Where(c => clientTypes.Contains(c.ApplicationType)); } var nbResult = result.Count(); if (parameter.Order != null) { switch (parameter.Order.Target) { case "update_datetime": switch (parameter.Order.Type) { case OrderTypes.Asc: result = result.OrderBy(c => c.UpdateDateTime); break; case OrderTypes.Desc: result = result.OrderByDescending(c => c.UpdateDateTime); break; } break; } } else { result = result.OrderByDescending(c => c.UpdateDateTime); } if (parameter.IsPagingEnabled) { result = result.Skip(parameter.StartIndex).Take(parameter.Count); } return(Task.FromResult(new SearchClientResult { Content = result.Select(s => s.Copy()), StartIndex = parameter.StartIndex, TotalResults = nbResult })); }
public Task <SearchResult <OAuthClient> > Find(SearchClientParameter parameter, CancellationToken token) { throw new NotImplementedException(); }
public Task <SearchClientResult> Search(SearchClientParameter parameter) { return(_searchClientsAction.Execute(parameter)); }
public async Task <SearchClientResult> Search(SearchClientParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } IQueryable <Client> clients = _context.Clients; if (parameter.ClientIds != null && parameter.ClientIds.Any()) { clients = clients.Where(c => parameter.ClientIds.Any(i => c.ClientId.Contains(i))); } if (parameter.ClientNames != null && parameter.ClientNames.Any()) { clients = clients.Where(c => parameter.ClientNames.Any(n => c.ClientName.Contains(n))); } if (parameter.ClientTypes != null && parameter.ClientTypes.Any()) { var clientTypes = parameter.ClientTypes.Select(t => (Models.ApplicationTypes)t); clients = clients.Where(c => clientTypes.Contains(c.ApplicationType)); } var nbResult = await clients.CountAsync().ConfigureAwait(false); if (parameter.Order != null) { switch (parameter.Order.Target) { case "update_datetime": switch (parameter.Order.Type) { case OrderTypes.Asc: clients = clients.OrderBy(c => c.UpdateDateTime); break; case OrderTypes.Desc: clients = clients.OrderByDescending(c => c.UpdateDateTime); break; } break; } } else { clients = clients.OrderByDescending(c => c.UpdateDateTime); } if (parameter.IsPagingEnabled) { clients = clients.Skip(parameter.StartIndex).Take(parameter.Count); } return(new SearchClientResult { Content = await clients.Select(c => c.ToDomain()).ToListAsync().ConfigureAwait(false), StartIndex = parameter.StartIndex, TotalResults = nbResult }); }