public async Task <IActionResult> Index()
        {
            var model = new IndexViewModel {
                AvailableChallenges = 0, UnfinishedChallenges = 0
            };

            var user = await _userManager.GetUserAsync(User);

            var aggregateResponse = await aggregateProvider.GetItemAsync("00000000-0000-0000-0000-000000000000");

            if (aggregateResponse.Item1.Success)
            {
                if (aggregateResponse.Item2 != null)
                {
                    model.AvailableChallenges = aggregateResponse.Item2.ChallengeTotals.TotalPublic;
                }
            }
            if (user != null)
            {
                var userChallengesResponse = await userChallengesProvider.GetItemAsync(user.Id);

                if (userChallengesResponse.Item1.Success)
                {
                    if (userChallengesResponse.Item2 != null)
                    {
                        model.UnfinishedChallenges = userChallengesResponse.Item2.Challenges.Where(c => !c.Completed).Count();
                    }
                }
            }

            return(View(model));
        }
        public async Task <IActionResult> Index()
        {
            var model = new IndexViewModel {
                Challenges = new List <Challenge>()
            };

            var challengesResponse = await challengesProvider.GetAllItemsAsync();

            if (challengesResponse.Item1.Success)
            {
                model.Challenges = challengesResponse.Item2
                                   .Where(c => c.IsPublic)
                                   .Select(c => new Models.ChallengeViewModels.Challenge
                {
                    Description       = c.Description,
                    Id                = c.Id,
                    Name              = c.Name,
                    CurrentQuestionId = c.Questions.Where(q => q.Index == 0).FirstOrDefault()?.Id,
                    IsComplete        = false,
                    IsUnderway        = false,
                    AzureCategory     = c.AzureServiceCategory,
                    WelcomeMessage    = c.WelcomeMessage,
                    PrereqLinks       = c.PrereqLinks
                })
                                   .ToList();
            }

            var user = await _userManager.GetUserAsync(User);

            var userChallengesResponse = await userChallengesProvider.GetItemAsync(user.Id);

            if (userChallengesResponse.Item1.Success)
            {
                if (userChallengesResponse.Item2 != null)
                {
                    foreach (var challenge in userChallengesResponse.Item2.Challenges)
                    {
                        // If a user is enrolled in a challenge, check if not finished and set the continuation question
                        if (!challenge.Completed)
                        {
                            var challengeInModel = model.Challenges.Where(p => p.Id == challenge.ChallengeId).FirstOrDefault();

                            if (challengeInModel != null)
                            {
                                challengeInModel.CurrentQuestionId = challenge.CurrentQuestion;
                                challengeInModel.IsUnderway        = true;
                            }
                        }
                        else
                        {
                            var challengeInModel = model.Challenges.Where(p => p.Id == challenge.ChallengeId).FirstOrDefault();

                            if (challengeInModel != null)
                            {
                                challengeInModel.IsComplete = true;
                            }
                        }
                    }
                }
            }

            return(View(model));
        }