Exemple #1
0
        public async Task <IActionResult> Index(int page = GlobalConstants.DefaultPageNumber)
        {
            var topics = this.topicsService.GetLatestTopics(page);

            var viewModel = new TopicsListingViewModel()
            {
                TotalTopicsCount = this.topicsService.GetTotalTopicsCount(),
                CurrentPage      = page,
                Topics           = topics,
                ForumStats       = await this.forumsService.GetForumStatsAsync(),
                Categories       = await this.categoriesService.GetAllAsync <CategoryInfoViewModel>(),
            };

            this.ViewData["Title"]             = "Home Page";
            this.ViewData["Controller/Action"] = "/Home/Index";

            return(this.View(viewModel));
        }
Exemple #2
0
        public async Task <IActionResult> Random(int page = GlobalConstants.DefaultPageNumber)
        {
            var topics = this.topicsService.GetRandomTopics(page);

            // var topicsList = topics.ToList().Where(t => t.CreatedOn > DateTime.Now.AddDays(-1)).OrderByDescending(t => t.CreatedOn);
            var viewModel = new TopicsListingViewModel()
            {
                TotalTopicsCount = this.topicsService.GetTotalTopicsCount(),
                CurrentPage      = page,
                Topics           = topics,
                ForumStats       = await this.forumsService.GetForumStatsAsync(),
                Categories       = await this.categoriesService.GetAllAsync <CategoryInfoViewModel>(),
            };

            this.ViewData["Title"]             = "Random Topics";
            this.ViewData["Controller/Action"] = "/Home/Random";

            return(this.View("Index", viewModel));
        }
Exemple #3
0
        public async Task <IActionResult> Following(int page = GlobalConstants.DefaultPageNumber)
        {
            var currentUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var serviceModel = this.topicsService.GetTopicsOfFollowedUsers(currentUserId, page);

            // var topicsList = topics.ToList().Where(t => t.CreatedOn > DateTime.Now.AddDays(-1)).OrderByDescending(t => t.CreatedOn);
            var viewModel = new TopicsListingViewModel()
            {
                TotalTopicsCount = serviceModel.TotalTopicsCount,
                CurrentPage      = page,
                Topics           = serviceModel.Topics,
                ForumStats       = await this.forumsService.GetForumStatsAsync(),
                Categories       = await this.categoriesService.GetAllAsync <CategoryInfoViewModel>(),
            };

            this.ViewData["Title"]             = "Followed Users Topics";
            this.ViewData["Controller/Action"] = "/Home/Following";

            return(this.View("Index", viewModel));
        }