public virtual ActionResult Index() { this.SaveUserVisit(); ForumOverview forumOverview = this.forumStorageReader.GetForumOverview(page: 1, topicsPerPage: 10, currentUsername: this.User.Identity.Name); IList <PhotoAlbumItemViewModel> newestAlbums = this.photoMetaDataStorage.GetNewestAlbums(count: 6); var viewModel = new HomeViewModel { ForumOverview = forumOverview, PhotosAlbums = newestAlbums }; return(this.View(viewModel)); }
public virtual ActionResult Index(int forumPage) { this.SaveUserVisit(); ForumOverview forumOverview = this.forumStorageReader.GetForumOverview(forumPage, ForumOptions.TopicsPerPage, this.User.Identity.Name); StaticPagedList <TopicOverviewViewModel> topics = new StaticPagedList <TopicOverviewViewModel>( forumOverview.TopicsForCurrentPage, forumPage, ForumOptions.TopicsPerPage, forumOverview.TotalNumberOfTopics); return(this.View(new ForumViewModel { Topics = topics })); }
public ForumOverview GetForumOverview(int page, int topicsPerPage, string currentUsername) { RavenQueryStatistics stats; ForumOverview forumOverview = new ForumOverview { TopicsForCurrentPage = this.ravenSession.Query <Topic>() .Statistics(out stats) .Where(t => !t.ExcludedUserNames.ContainsAny(new[] { currentUsername })) .OrderByDescending(topic => topic.DisplayPriority) .ThenByDescending(topic => topic.LastPostTime) .Skip((page - 1) * topicsPerPage) .Take(topicsPerPage) // todo move the transformation to raven db .ToList() .Select(topic => new TopicOverviewViewModel(topic, currentUsername)) .ToList(), TotalNumberOfTopics = stats.TotalResults }; return(forumOverview); }