public ArticleSearchResult FindArticle(int?year, int?month, int?day, string title, string keyword) { var result = new ArticleSearchResult { TotalCount = 1 }; return(result); }
public ListsSearchArticlesViewModel(ControllerContext controllerContext, string searchTerm) { this.SearchTerm = searchTerm ?? string.Empty; if (string.IsNullOrWhiteSpace(this.SearchTerm)) { this.SearchResults = new List<SearchItem>(0); this.Suggestions = new List<string>(0); return; } var searchTermArticleSlug = new ArticleSlug(this.SearchTerm); this.SearchTermFormatted = Capitalize(searchTermArticleSlug.Title); var repository = controllerContext.HttpContext.GetRepository(); var searchQuery = repository.QueryArticlesSearch(this.SearchTerm); var searchResult = new ArticleSearchResult(searchQuery); this.SearchResults = searchResult.Items.Select(x => new SearchItem(x)).ToList(); this.Suggestions = searchResult.Suggestions; var articleRedirect = repository.GetArticleRedirect(searchTermArticleSlug); var articleSlugStatus = repository.GetArticleSlugStatus(searchTermArticleSlug); this.ArticleExists = articleSlugStatus.HasAnySlug || (articleRedirect != null); var redirectArticleSlug = (articleRedirect != null) ? new ArticleSlug(articleRedirect.TargetArticleSlug) : null; bool isRedirect = (redirectArticleSlug != null) && (redirectArticleSlug.Title != SearchTermFormatted); this.ArticleTitle = this.ArticleExists ? (isRedirect ? redirectArticleSlug.Title : this.SearchTermFormatted) : this.SearchTermFormatted; this.ArticleRedirectedFromTitle = (this.ArticleExists && isRedirect) ? this.SearchTermFormatted : null; }