public async Task <ActionResult> Index() { var currentUserId = User.Identity.GetUserId(); TriviaDashboardViewModel viewModel = new TriviaDashboardViewModel(); viewModel.NewQuizzes = await TriviaService.GetNewQuizzesAsync(); viewModel.DailyQuizzes = await TriviaService.GetDailyQuizzesAsync(5); viewModel.TrendingQuizzes = await GetTrendingQuizzesAsync(); viewModel.PopularQuizzes = await GetPopularQuizzesAsync(); // unauthenticated users don't have any quizzes to track if (User.Identity.IsAuthenticated) { viewModel.UnfinishedQuizzes = await TriviaService.GetUnfinishedQuizzesAsync(User.Identity.GetUserId()); } // alters the viewmodel's list of quizzes to indicate if the quiz has already been completed by the currently logged in user await SetQuizzesCompletedByCurrentUser(currentUserId, viewModel); viewModel.RecentlyCompletedQuizzes = await TriviaService.GetUsersCompletedQuizzesAsync(currentUserId); viewModel.QuizCategories = await TriviaService.GetQuizCategoriesAsync(); await SetNotificationsAsync(); return(View(viewModel)); }