Inheritance: _LayoutViewModel
コード例 #1
0
ファイル: HomeController.cs プロジェクト: omarq/RavenOverflow
        public ActionResult AggressiveIndex(string displayName, string tag)
        {
            using (DocumentSession.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(1)))
            {
                string header;

                // 1. All the questions, ordered by most recent.
                Lazy<IEnumerable<QuestionWithDisplayName>> questionsQuery = QuestionQuery(tag, out header).Lazily();

                // 2. Popular Tags for a time period.
                // StackOverflow calls it 'recent tags'.
                Lazy<IEnumerable<RecentPopularTags.ReduceResult>> recentPopularTags = RecentPopularTagsQuery().Lazily();

                // 3. Log in user information.
                IQueryable<User> userQuery = UserQuery(displayName);
                Lazy<IEnumerable<User>> lazyUserQuery = (userQuery != null ? userQuery.Lazily() : null);

                var viewModel = new IndexViewModel(User.Identity)
                                    {
                                        Header = header,
                                        QuestionListViewModel = new QuestionListViewModel
                                                                    {
                                                                        Questions = questionsQuery.Value.ToList()
                                                                    },
                                        RecentPopularTags =
                                            recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
                                        UserFavoriteTagListViewModel = new UserTagListViewModel
                                                                           {
                                                                               Header = "Favorite Tags",
                                                                               DivId1 = "interesting-tags",
                                                                               DivId2 = "interestingtags",
                                                                               Tags = lazyUserQuery == null
                                                                                          ? null
                                                                                          : (lazyUserQuery.Value.
                                                                                                 SingleOrDefault() ??
                                                                                             new User()).FavoriteTags
                                                                           },
                                        UserIgnoredTagList = new UserTagListViewModel
                                                                 {
                                                                     Header = "Ignored Tags",
                                                                     DivId1 = "ignored-tags",
                                                                     DivId2 = "ignoredtags",
                                                                     Tags = null
                                                                 }
                                    };

                return View("Index", viewModel);
            }
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: omarq/RavenOverflow
        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. Log in user information.
            IQueryable<User> userQuery = UserQuery(displayName);

            var viewModel = new IndexViewModel(User.Identity)
                                {
                                    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);
        }
コード例 #3
0
        public ActionResult BatchedIndex(string displayName, string tag)
        {
            string header;

            // 1. All the questions, ordered by most recent.
            var questionsQuery = QuestionQuery(tag, out header).Lazily();

            // 2. Popular Tags for a time period.
            // StackOverflow calls it 'recent tags'.
            var recentPopularTags = RecentPopularTagsQuery().Lazily();

            // 3. Log in user information.
            var userQuery = UserQuery(displayName);
            var lazyUserQuery = (userQuery != null ? userQuery.Lazily() : null);

            var viewModel = new IndexViewModel(User.Identity)
                                {
                                    Header = header,
                                    Questions = questionsQuery.Value.ToList(),
                                    RecentPopularTags = recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
                                    UserFavoriteTagListViewModel = new UserTagListViewModel
                                                              {
                                                                  Header = "Favorite Tags",
                                                                  DivId1 = "interesting-tags",
                                                                  DivId2 = "interestingtags",
                                                                  Tags = lazyUserQuery == null ? null :
                                                                      (lazyUserQuery.Value.SingleOrDefault() ?? new User()).FavoriteTags
                                                              },
                                    UserIgnoredTagList = new UserTagListViewModel
                                                             {
                                                                 Header = "Ignored Tags",
                                                                 DivId1 = "ignored-tags",
                                                                 DivId2 = "ignoredtags",
                                                                 Tags = null
                                                             }
                                };

            return View("Index", viewModel);
        }