예제 #1
0
        public IEnumerable <ProviderSummary> GetAllProviders()
        {
            var take    = _queryHelper.GetProvidersTotalAmount();
            var results =
                _elasticsearchCustomClient.Search <Provider>(
                    s =>
                    s.Index(_applicationSettings.ProviderIndexAlias)
                    .From(0)
                    .Sort(sort => sort.Ascending(f => f.Ukprn))
                    .Take(take)
                    .Query(q => + q.Term("documentType", ProviderIndexType)));

            if (results.ApiCall.HttpStatusCode != 200)
            {
                _applicationLogger.LogWarning($"httpStatusCode was {results.ApiCall.HttpStatusCode}");
                throw new ApplicationException("Failed query all providers");
            }

            return(results.Documents.Select(provider => _providerMapping.MapToProviderDto(provider)).ToList());
        }