Exemplo n.º 1
0
        public async Task <IActionResult> SearchPages(string searchPattern, int start, int pageSize, string excludeId)
        {
            if (searchPattern == null)
            {
                searchPattern = "";
            }

            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            Task <List <KirjaPage> > queryTask;
            Task <int> countTask;

            queryTask = _pageDbAccess.SearchPages(project.Id, searchPattern, start, pageSize, excludeId);
            countTask = _pageDbAccess.SearchPagesCount(project.Id, searchPattern, excludeId);
            Task.WaitAll(queryTask, countTask);

            PageQueryResult queryResult = new PageQueryResult();

            queryResult.Pages   = queryTask.Result;
            queryResult.HasMore = start + queryResult.Pages.Count < countTask.Result;
            return(Ok(queryResult));
        }