예제 #1
0
        public async Task <IActionResult> Index(int page = 1)
        {
            // Retrieves the threads at the front page
            IEnumerable <Thread> threads = await _repository.GetFrontPageAsync(page);

            // Checks if the user's email is verified and sets EmailVerified accordingly
            bool emailVerified             = false;
            bool emailVerificationRequired = _config.RequireEmailVerification;

            if (User.Identity.IsAuthenticated)
            {
                User user = await _repository.GetUserAsync(User);

                emailVerified = user.Activated;
            }

            // Sets thread and page variables and returns view
            IndexViewModel model = new IndexViewModel()
            {
                Threads                   = threads,
                Page                      = page,
                PageCount                 = await _repository.GetPageCountAsync(),
                EmailVerified             = emailVerified,
                EmailVerificationRequired = emailVerificationRequired
            };

            return(View(model));
        }
예제 #2
0
        public async Task <IEnumerable <ApiThread> > GetFrontPage(int page = 1)
        {
            IEnumerable <Thread> threads = await _repository.GetFrontPageAsync(page);

            return(threads.Select(x => new ApiThread(x)));
        }