public IEnumerable <Organisation> GetOrganisationsByStandardId(string standardId)
        {
            var take = GetOrganisationsAmountByStandardId(standardId);

            var results =
                _elasticsearchCustomClient.Search <StandardOrganisationDocument>(
                    s =>
                    s.Index(_applicationSettings.AssessmentOrgsIndexAlias)
                    .Type(Types.Parse("standardorganisationdocument"))
                    .From(0)
                    .Take(take)
                    .Query(q => q
                           .Match(m => m
                                  .Field(f => f.StandardCode)
                                  .Query(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);

            return(_assessmentOrgsMapping.MapToOrganisationsDetailsDto(organisations));
        }
Пример #2
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));
        }