Esempio n. 1
0
        /// <summary>
        /// Finds the specified model.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public async Task <PagedResultDto <ScaleAnswerSetResponseDto> > Find(int customerId, TagsSearchDto model = null)
        {
            var result = await scaleAnswerSetService.Find(customerId, model);

            return(Mapper.Map <PagedResult <ScaleAnswerSet>, PagedResultDto <ScaleAnswerSetResponseDto> >(result));
        }
Esempio n. 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);
        }