/// <summary>
        /// Returns list of Assessment elements models for specified customer.
        /// Copies data from CI customer to specified if required customer didn't have any Assessment elements.
        /// </summary>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public async Task <PagedResultDto <AssessmentResponseDto> > GetAll(int customerId, TagsSearchDto request)
        {
            var result = await AssessmentElementsService.GetAll(customerId, request);

            return(Mapper.Map <PagedResult <AssessmentElement>, PagedResultDto <AssessmentResponseDto> >(result));
        }
Ejemplo 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);
        }