/// <summary> /// Finds the answer sets. /// </summary> /// <param name="searchAnswerSetModel">The search answer set model.</param> /// <returns></returns> public async Task <SearchAnswerSetResultDto> FindAnswerSets(SearchAnswerSetViewModel searchAnswerSetModel) { var searchResult = new SearchAnswerSetResultDto() { SelectionAnswerSets = new List <UpdateSelectionAnswerSetViewModel>(), ScaleAnswerSets = new List <SearchScaleAnswerSetResultViewModel>() }; var searchScaleAnswersetRequest = new SearchRequestDto() { CustomerId = this.customerContext.Customer.Id, Q = searchAnswerSetModel.Keyword, Tags = new string[] { searchAnswerSetModel.Tag } }; var searchSelectionAnswerSetRequest = new SearchSelectionRequestDto() { CustomerId = this.customerContext.Customer.Id, Q = searchAnswerSetModel.Keyword, Tags = new[] { searchAnswerSetModel.Tag }, IsMultipleChoice = false }; var searchCheckListAnswerSetRequest = new SearchSelectionRequestDto() { CustomerId = this.customerContext.Customer.Id, Q = searchAnswerSetModel.Keyword, Tags = new[] { searchAnswerSetModel.Tag }, IsMultipleChoice = true }; string authToken = this.authDataStorage.GetToken(); if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.All) { var mappedSelectionAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchSelectionAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedSelectionAnswerSets); var mappedChecklistAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchCheckListAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedChecklistAnswerSets); var mappedScaleAnswerSets = (await this.healthLibraryService.FindScaleAnswerSets(searchScaleAnswersetRequest, authToken)).Select (Mapper.Map <SearchScaleAnswerSetResultViewModel>); searchResult.ScaleAnswerSets.AddRange(mappedScaleAnswerSets); } else if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.CheckList) { var mappedChecklistAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchCheckListAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedChecklistAnswerSets); } else if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.MultipleChoice) { var mappedSelectionAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchSelectionAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedSelectionAnswerSets); } else if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.ScaleAnswerSet) { var scaleAnswerSets = await this.healthLibraryService.FindScaleAnswerSets(searchScaleAnswersetRequest, authToken); var mappedScaleAnswerSets = scaleAnswerSets.Select(Mapper.Map <SearchScaleAnswerSetResultViewModel>); searchResult.ScaleAnswerSets.AddRange(mappedScaleAnswerSets); } return(searchResult); }
public async Task <JsonResult> FindAnswerSets(SearchAnswerSetViewModel searchAnswerSetModel) { var searchResult = await this.careBuilderManager.FindAnswerSets(searchAnswerSetModel); return(this.Json(searchResult, JsonRequestBehavior.AllowGet)); }