public ActionResult Index(string displayName, string tag)
{
string header;
// 1. All the questions, ordered by most recent.
IQueryable<QuestionWithDisplayName> questionsQuery = QuestionQuery(tag, out header);
// 2. Popular Tags for a time period.
// StackOverflow calls it 'recent tags'.
IQueryable<RecentPopularTags.ReduceResult> recentPopularTags = RecentPopularTagsQuery();
// 3. Logged in user information.
IQueryable<User> userQuery = UserQuery(displayName);
var viewModel = new IndexViewModel(ClaimsUser)
{
Header = header,
QuestionListViewModel = new QuestionListViewModel
{
Questions = questionsQuery.ToList()
},
RecentPopularTags = recentPopularTags.ToDictionary(x => x.Tag, x => x.Count),
UserFavoriteTagListViewModel = new UserTagListViewModel
{
Header = "Favorite Tags",
DivId1 = "interesting-tags",
DivId2 = "interestingtags",
Tags = userQuery == null
? null
: (userQuery.SingleOrDefault() ??
new User()).FavoriteTags
},
UserIgnoredTagList = new UserTagListViewModel
{
Header = "Ignored Tags",
DivId1 = "ignored-tags",
DivId2 = "ignoredtags",
Tags = null
}
};
return View(viewModel);
}