コード例 #1
0
        /// <summary>
        /// Returns model with search results.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="criteria">The criteria.</param>
        /// <param name="isBrief">if set to <c>true</c> [is brief].</param>
        /// <returns></returns>
        public async Task <PagedResultDto <QuestionElementResponseDto> > Find(int customerId, TagsSearchDto criteria, bool isBrief)
        {
            var result = await questionElementService.Find(customerId, criteria);

            return(Mapper.Map <PagedResult <QuestionElement>, PagedResultDto <QuestionElementResponseDto> >(
                       result,
                       o => o.Items.Add("isBrief", isBrief)
                       ));
        }
コード例 #2
0
        /// <summary>
        /// Gets all cached entries.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <returns></returns>
        public async Task <ConcurrentDictionary <Guid, SearchEntryDto> > GetAllCachedEntries(int customerId)
        {
            var cacheKey = string.Format(SearchIndexKeyTemplate, customerId);

            var allCachedEntries =
                await cacheProvider.Get <ConcurrentDictionary <Guid, SearchEntryDto> >(
                    cacheKey, async() =>
            {
                var result = new ConcurrentDictionary <Guid, SearchEntryDto>();

                var programs          = (await programService.FindPrograms(customerId)).Results;
                var programsResponses = Mapper.Map <IList <Program>, IList <SearchProgramResponseDto> >(programs);

                foreach (var program in programsResponses)
                {
                    result.TryAdd(program.Id, program);
                }

                var protocols = Mapper.Map <IList <Protocol>, IList <SearchEntryDto> >((await protocolService.GetProtocols(customerId)).Results);

                foreach (var protocol in protocols)
                {
                    result.TryAdd(protocol.Id, protocol);
                }

                var measurementElements = Mapper.Map <IList <MeasurementElement>, IList <SearchEntryDto> >((await measurementElementsService.GetAll(customerId)).Results);

                foreach (var measurementElement in measurementElements)
                {
                    result.TryAdd(measurementElement.Id, measurementElement);
                }

                var assessmentElements = Mapper.Map <IList <AssessmentElement>, IList <SearchEntryDto> >((await assessmentElementsService.GetAll(customerId)).Results);

                foreach (var assessmentElement in assessmentElements)
                {
                    result.TryAdd(assessmentElement.Id, assessmentElement);
                }

                var questionElements = Mapper.Map <IList <QuestionElement>, IList <SearchEntryDto> >((await questionElementService.Find(customerId)).Results);

                foreach (var questionElement in questionElements)
                {
                    result.TryAdd(questionElement.Id, questionElement);
                }

                var textMediaElements = Mapper.Map <IList <TextMediaElement>, IList <SearchTextAndMediaDto> >((await textMediaElementsService.GetElements(customerId)).Results);

                foreach (var textMediaElement in textMediaElements)
                {
                    result.TryAdd(textMediaElement.Id, textMediaElement);
                }

                var scaleAnswerSets = Mapper.Map <IList <ScaleAnswerSet>, IList <SearchEntryDto> >((await scaleAnswerSetService.Find(customerId)).Results);

                foreach (var scaleAnswerSet in scaleAnswerSets)
                {
                    result.TryAdd(scaleAnswerSet.Id, scaleAnswerSet);
                }

                var selectionAnswerSets = Mapper.Map <IList <SelectionAnswerSet>, IList <SearchEntryDto> >((await selectionAnswerSetService.Find(customerId)).Results);

                foreach (var selectionAnswerSet in selectionAnswerSets)
                {
                    result.TryAdd(selectionAnswerSet.Id, selectionAnswerSet);
                }

                var openEndedAnswerSet = Mapper.Map <AnswerSet, SearchEntryDto>(await openEndedAnswerSetsService.Get(customerId));

                result.TryAdd(openEndedAnswerSet.Id, openEndedAnswerSet);

                return(result);
            }
                    );

            return(allCachedEntries);
        }