private static SearchScopeParameter ToSearchScopeParameter(IEnumerable <KeyValuePair <string, string> > queries) { var result = new SearchScopeParameter(); result.ExtractSearchParameter(queries); return(result); }
public async Task <JObject> Handle(SearchScopeParameter parameter, CancellationToken cancellationToken) { var result = await _oauthScopeRepository.Find(parameter, cancellationToken); return(new JObject { { "start_index", result.StartIndex }, { "count", result.Count }, { "total_length", result.TotalLength }, { "content", new JArray(result.Content.Select(c => c.ToDto())) } }); }
public Task <SearchResult <OAuthScope> > Find(SearchScopeParameter parameter, CancellationToken cancellationToken) { var result = _scopes.AsQueryable(); if (MAPPING_SCOPE_TO_PROPERTYNAME.ContainsKey(parameter.OrderBy)) { result = result.InvokeOrderBy(MAPPING_SCOPE_TO_PROPERTYNAME[parameter.OrderBy], parameter.Order); } int totalLength = result.Count(); result = result.Skip(parameter.StartIndex).Take(parameter.Count); return(Task.FromResult(new SearchResult <OAuthScope> { StartIndex = parameter.StartIndex, Count = parameter.Count, TotalLength = totalLength, Content = result.ToList() })); }