public ActionResult SideBar(State state)
        {
            var articles = _service.ArticlesByState(state, size: 5).ToList();

            var viewModel = new SideBarViewModel
            {
                CurrentState = state,
                SpotLightArticles = articles.Select(x => x.Title),
                RecentArticles = articles,
                PopularArticles = _service.GetPopularArticles(),
                RecentlyCommentArticles = Enumerable.Empty<Article>(), // _service.GetRecentlyCommentedArticles(),
                PopularTags = _tagService.GetTagsByState(state).Select(x => x.Name),
                LatestPhotos = articles
                    .Select(x => x.ImageUrl)
            };

            return PartialView("~/Views/Shared/SideBar.cshtml", viewModel);
        }
예제 #2
0
        public ActionResult SideBar(State state)
        {
            var articles = _service.ArticlesByState(state);

            var viewModel = new SideBarViewModel
            {
                CurrentState = state,
                SpotLightArticles = articles
                    .Skip(0).Take(5)
                    .Select(x => x.Title),

                RecentArticles = articles
                    .Skip(0).Take(5),

                PopularArticles = articles
                    .OrderByDescending(x => x.Views)
                    .Skip(0).Take(5),

                RecentlyCommentArticles = articles
                    .Where(x => x.Comments.Any())
                    .OrderByDescending(x => x.Comments.OrderByDescending(y => y.DateCreated).FirstOrDefault().DateCreated)
                    .Skip(0).Take(5),

                PopularTags = _tagService.GetTagsByState(state)
                    .OrderByDescending(x => x.Articles.Count)
                    .Skip(0).Take(10)
                    .Select(x => x.Name),

                LatestPhotos = articles
                    .Skip(0).Take(5)
                    .Select(x => x.ImageUrl)
            };

            return PartialView("~/Views/Shared/SideBar.cshtml", viewModel);
        }