Пример #1
0
        public async Task <IEnumerable <Assessment> > Search(AssessmentSearchParams search)
        {
            if (search == null)
            {
                throw new ArgumentNullException(nameof(search));
            }

            var odsApi = await _odsApiClientProvider.NewResourcesClient();

            var assessmentsFromApi = await odsApi.Get <IList <AssessmentModelv3> >("assessments");

            var mappedStandard = assessmentsFromApi.Select(b => b.MapToAssessmentv2()).ToList();

            return(await ApplySearchParams(mappedStandard, search));
        }
Пример #2
0
        public async Task <IEnumerable <Assessment> > Search(AssessmentSearchParams searchParams)
        {
            if (searchParams == null)
            {
                throw new ArgumentNullException(nameof(searchParams));
            }

            var ods = await _odsApiClientProvider.NewResourcesClient();

            var assessmentsFromApi = await ods.Get <IEnumerable <Assessment> >("assessments", new Dictionary <string, string>
            {
                ["limit"] = "100",
            });

            return(await ApplySearchParams(assessmentsFromApi, searchParams));
        }
Пример #3
0
        private async Task <IEnumerable <Assessment> > ApplySearchParams(IEnumerable <Assessment> assessments, AssessmentSearchParams searchParams)
        {
            assessments = await ApplyNamespace(assessments, searchParams.CurrentNamespace);

            assessments = AssessmentSortFields.IsSortFieldValid(searchParams.SortField)
                ? ApplySorting(assessments, searchParams.SortField, searchParams.SortDesc)
                : ApplySorting(assessments, AssessmentSortFields.Default, searchParams.SortDesc);

            assessments = !string.IsNullOrWhiteSpace(searchParams.SearchValue)
                ? ApplySearchValue(assessments, searchParams.SearchValue)
                : assessments;

            assessments = searchParams.PageIndex.HasValue && searchParams.PageSize.HasValue
                ? ApplyPagination(assessments, searchParams.PageIndex.Value, searchParams.PageSize.Value)
                : assessments;

            return(assessments);
        }