示例#1
0
        public IEnumerable <Organisation> GetOrganisationsByStandardId(string standardId)
        {
            var take = _queryHelper.GetOrganisationsAmountByStandardId(standardId);

            var results =
                _elasticsearchCustomClient.Search <StandardOrganisationDocument>(
                    s =>
                    s.Index(_applicationSettings.AssessmentOrgsIndexAlias)
                    .From(0)
                    .Take(take)
                    .Query(q => + q.Term("documentType", "standardorganisationdocument") && +q.Term(f => f.StandardCode.Suffix("keyword"), standardId)));

            if (results.ApiCall.HttpStatusCode != 200)
            {
                throw new ApplicationException("Failed query organisations by standard id");
            }

            var organisations = results.Documents.Where(x => x.EffectiveFrom.Date <= DateTime.UtcNow.Date && (x.EffectiveTo == null || x.EffectiveTo.Value.Date >= DateTime.UtcNow.Date)).ToList();

            return(_assessmentOrgsMapping.MapToOrganisationsDetailsDto(organisations));
        }