public async Task <IActionResult> Index()
        {
            var    correlationId = Guid.NewGuid();
            string sessionId     = null;

            try
            {
                sessionId = await TryGetSessionId(Request);

                if (string.IsNullOrEmpty(sessionId))
                {
                    return(Redirect("/"));
                }

                var resultsResponse = await _apiServices.Results(sessionId, correlationId);

                var lastFilterResult = resultsResponse.JobCategories
                                       .Where(x => x.FilterAssessmentResult != null)
                                       .OrderByDescending(x => x.FilterAssessmentResult.CreatedDt)
                                       .Select(x => x.FilterAssessmentResult)
                                       .FirstOrDefault();
                if (lastFilterResult != null)
                {
                    AppendCookie(sessionId);
                    return(Redirect($"/results/{lastFilterResult.JobFamilyNameUrlSafe}"));
                }

                var model = new ResultsViewModel
                {
                    SessionId             = sessionId,
                    Code                  = SaveProgressController.GetDisplayCode(sessionId.Split("-")[1]),
                    AssessmentType        = resultsResponse.AssessmentType,
                    JobCategories         = resultsResponse.JobCategories,
                    JobFamilyCount        = resultsResponse.JobFamilyCount,
                    JobFamilyMoreCount    = resultsResponse.JobFamilyMoreCount,
                    Traits                = resultsResponse.Traits,
                    UseFilteringQuestions = _appSettings.UseFilteringQuestions,
                    JobProfiles           = resultsResponse.JobProfiles,
                    ExploreCareersBaseUrl = _appSettings.ExploreCareersBaseUrl
                };
                return(View("Results", model));
            }
            catch (System.Net.Http.HttpRequestException ex)
            {
                _log.LogError(ex, $"Correlation Id: {correlationId} - A dependency error occurred rendering action {nameof(Index)}");
                if (!string.IsNullOrEmpty(sessionId))
                {
                    return(Redirect("/reload"));
                }
                return(Redirect("/"));
            }
            catch (Exception ex)
            {
                _log.LogError(ex, $"Correlation Id: {correlationId} - An error occurred rendering action {nameof(Index)}");
                return(RedirectToAction("Error500", "Error"));
            }
        }
        private IActionResult ReturnResultsView(ResultsResponse resultsResponse, string jobCategory, string sessionId)
        {
            var model = new ResultsViewModel
            {
                SessionId             = sessionId,
                Code                  = SaveProgressController.GetDisplayCode(sessionId.Split("-")[1]),
                AssessmentType        = resultsResponse.AssessmentType,
                JobCategories         = ReOrderWithFirst(resultsResponse.JobCategories, jobCategory),
                JobFamilyCount        = resultsResponse.JobFamilyCount,
                JobFamilyMoreCount    = resultsResponse.JobFamilyMoreCount,
                Traits                = resultsResponse.Traits,
                UseFilteringQuestions = _appSettings.UseFilteringQuestions,
                JobProfiles           = resultsResponse.JobProfiles,
                WhatYouToldUs         = resultsResponse.WhatYouToldUs,
                ExploreCareersBaseUrl = _appSettings.ExploreCareersBaseUrl
            };


            return(View("ResultsForJobCategory", model));
        }