/// <summary>
        /// Returns list of question elements which matches to search criteria.
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        public async Task <IEnumerable <QuestionElementListItemViewModel> > FindQuestionElements(
            SearchCareElementsViewModel searchModel)
        {
            var searchRequest = new SearchRequestDto
            {
                Q          = searchModel.Keyword,
                CustomerId = CustomerContext.Current.Customer.Id
            };

            var result = await this.healthLibraryService.FindQuestionElements(searchRequest, authDataStorage.GetToken());

            return(result.Select(Mapper.Map <QuestionElementListItemViewModel>).ToList());
        }
        /// <summary>
        /// Returns list of selection answer sets which matches to search criteria.
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        public async Task <IEnumerable <UpdateSelectionAnswerSetViewModel> > FindSelectionAnswerSets(
            SearchCareElementsViewModel searchModel)
        {
            var searchRequest = new SearchSelectionRequestDto
            {
                IsMultipleChoice = false,
                Q          = searchModel.Keyword,
                CustomerId = CustomerContext.Current.Customer.Id
            };

            var result = await this.healthLibraryService
                         .FindSelectionAnswerSets(
                searchRequest,
                authDataStorage.GetToken()
                );

            return(result.Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>).ToList());
        }
        public async Task <ActionResult> GetSelectionAnswerSets(SearchCareElementsViewModel searchCriteria)
        {
            var result = await careBuilderManager.FindSelectionAnswerSets(searchCriteria);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        /// <summary>
        /// Returns list of text elements from API.
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        public async Task <IEnumerable <TextMediaResponseViewModel> > FindTextMediaElements(SearchCareElementsViewModel searchModel)
        {
            var searchRequest = new SearchRequestDto
            {
                Q          = searchModel.Keyword,
                CustomerId = CustomerContext.Current.Customer.Id
            };

            var token  = authDataStorage.GetToken();
            var result = await healthLibraryService.FindTextMediaElements(searchRequest, token);

            return(result.Select(textMediaElementDto => {
                var textMediaElementModel = Mapper.Map <TextMediaResponseViewModel>(textMediaElementDto);

                if (textMediaElementDto.Media == null)
                {
                    textMediaElementModel.Media = null;
                }
                else
                {
                    //var mediaElementDto = this.healthLibraryService.GetMediaElement(CustomerContext.Current.Customer.Id, textMediaElementDto.Media.MediaId, token);

                    //textMediaElementModel.Media = new MediaElementModel() { Name = "dummy name", ContentType = "dummy content type", FileName = "dummy file name" };
                    textMediaElementModel.Media = null;
                }

                /*
                 * textMediaElementDto.Media.IfNotNull(
                 *  dto =>
                 *      {
                 *          var mediaElementDto = this.healthLibraryService.GetMediaElement(CustomerContext.Current.Customer.Id, dto.MediaId, token);
                 *          textMediaElementModel.Media = Mapper.Map<MediaElementModel>(mediaElementDto);
                 *      });
                 */
                return textMediaElementModel;
            }).ToList());
        }