private FaqListModel GetFaq(Guid id, string keywords) { var faq = _faqsQuery.GetFaq(id); if (faq == null) { return(null); } var categories = _faqsQuery.GetCategories(); var criteria = new FaqSearchCriteria { SubcategoryId = faq.SubcategoryId, CategoryId = categories.GetCategoryBySubcategory(faq.SubcategoryId).Id, Keywords = keywords, }; return(new FaqListModel { Categories = categories, Criteria = criteria, UserType = GetUserType(categories, criteria.CategoryId), IsSingleFaq = true, Results = new FaqListResultsModel { FaqIds = new[] { faq.Id }, Faqs = new[] { faq }.ToDictionary(f => f.Id, f => f), TotalFaqs = 1, }, }); }
private FaqListModel GetFaqList(Guid?categoryId, string keywords) { var categories = _faqsQuery.GetCategories(); var category = (categoryId == null ? null : categories.GetCategory(categoryId.Value)) ?? categories.Single(c => c.Name == DefaultCategory); var criteria = new FaqSearchCriteria { CategoryId = category.Id, Keywords = keywords }; return(GetFaqList(criteria, categories)); }
private FaqListModel GetFaqList(FaqSearchCriteria criteria, IList <Category> categories) { var execution = _executeFaqSearchCommand.Search(criteria, null); return(new FaqListModel { Categories = categories, Criteria = execution.Criteria, UserType = GetUserType(categories, criteria.CategoryId), IsSingleFaq = false, Results = new FaqListResultsModel { TotalFaqs = execution.Results.ResourceIds.Count, FaqIds = execution.Results.ResourceIds, Faqs = _faqsQuery.GetFaqs(execution.Results.ResourceIds).ToDictionary(f => f.Id, f => f), }, }); }
private FaqListModel GetFaqList(Guid subcategoryId) { var categories = _faqsQuery.GetCategories(); var category = categories.GetCategoryBySubcategory(subcategoryId); if (category == null) { return(null); } var criteria = new FaqSearchCriteria { SubcategoryId = subcategoryId, CategoryId = category.Id, }; return(GetFaqList(criteria, categories)); }
FaqSearchExecution IExecuteFaqSearchCommand.Search(FaqSearchCriteria criteria, Range range) { ResourceSearchResults results; var service = _serviceManager.Create(); try { results = service.Search(criteria.GetSearchQuery(range), true); } catch (Exception) { _serviceManager.Abort(service); throw; } _serviceManager.Close(service); return(new FaqSearchExecution { Criteria = criteria, Results = results }); }
IResourceHighlighter IFaqHighlighterFactory.Create(ResourceHighlighterKind kind, FaqSearchCriteria criteria, HighlighterConfiguration configuration) { if (kind == ResourceHighlighterKind.Null || criteria == null) { return(new NullResourceHighlighter()); } var searchQuery = criteria.GetSearchQuery(null); var contentQuery = new QueryBuilder(_defaultQueryAnalyzer).GetContentQuery(searchQuery); return(new FaqHighlighter(contentQuery, _defaultContentAnalyzer, configuration)); }