예제 #1
0
        public async Task WhenHasPreviousCompleteCategoryRedirectsToRoles()
        {
            var category           = "testcategory";
            var assessmentResponse = new GetAssessmentResponse()
            {
                IsFilterAssessment = true, MaxQuestionsCount = 2, RecordedAnswersCount = 2,
            };

            A.CallTo(() => sessionService.HasValidSession()).Returns(true);
            A.CallTo(() => assessmentService.GetAssessment()).Returns(assessmentResponse);

            var resultsResponse = new GetResultsResponse()
            {
                JobCategories = GetJobCategories(category)
            };

            A.CallTo(() => resultsService.GetResults()).Returns(resultsResponse);

            var actionResponse = await controller.Index().ConfigureAwait(false);

            Assert.IsType <RedirectResult>(actionResponse);
            var redirectResult = actionResponse as RedirectResult;

            Assert.Equal($"~/{RouteName.Prefix}/results/roles/{category}", redirectResult.Url);
        }
예제 #2
0
        public async Task <IActionResult> Index()
        {
            if (!await HasSessionId().ConfigureAwait(false))
            {
                return(RedirectToRoot());
            }

            var assessmentResponse = await apiService.GetAssessment().ConfigureAwait(false);

            if (assessmentResponse == null)
            {
                logService.LogInformation("Assesment is null");
                return(RedirectTo("assessment/return"));
            }

            logService.LogInformation("Assessment is not null");

            var resultsResponse = await resultsService.GetResults().ConfigureAwait(false);

            var lastFilterCategory = resultsResponse.JobCategories
                                     .Where(x => x.FilterAssessment != null)
                                     .OrderByDescending(x => x.FilterAssessment.CreatedDt)
                                     .FirstOrDefault();

            if (lastFilterCategory != null)
            {
                return(RedirectTo($"results/roles/{lastFilterCategory.JobFamilyNameUrl}"));
            }

            var resultIndexResponseViewModel = new ResultIndexResponseViewModel
            {
                Results             = mapper.Map <ResultsIndexResponseViewModel>(resultsResponse),
                AssessmentReference = assessmentResponse.ReferenceCode,
            };

            logService.LogInformation("About to display results view");
            return(View(resultIndexResponseViewModel));
        }
 public ActionResult <IEnumerable <TableModel> > GetResults(int resultId = 1)
 {
     try
     {
         return(Ok(_resultService.GetResults(resultId)));
     }
     catch (BadRequestOperationException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}"));
     }
 }
예제 #4
0
        public async Task GetResults()
        {
            //Arrange
            var category        = "ACategory";
            var resultsResponse = new GetResultsResponse()
            {
                SessionId = sessionId
            };
            List <JobProfileResult> profiles = new List <JobProfileResult>
            {
                new JobProfileResult()
                {
                    UrlName = category, JobCategory = category
                }
            };

            resultsResponse.JobProfiles = profiles;

            List <JobCategoryResult> categories = new List <JobCategoryResult>
            {
                new JobCategoryResult()
                {
                    JobFamilyName = category, JobFamilyUrl = category
                }
            };

            resultsResponse.JobCategories = categories;

            A.CallTo(() => resultsApiService.GetResults(sessionId, A <string> .Ignored)).Returns(resultsResponse);

            //Act
            var results = await resultsService.GetResults();

            //Assert
            A.CallTo(() => resultsApiService.GetResults(sessionId, A <string> .Ignored)).MustHaveHappenedOnceExactly();
            results.SessionId.Should().Be(sessionId);
            results.JobCategories.FirstOrDefault().NumberOfMatchedJobProfile.Should().Be(1);
        }
 public IEnumerable <SubjectResult> Get()
 {
     return(_resultsService.GetResults());
 }
        public IActionResult Index()
        {
            var results = _resultsService.GetResults();

            return(View(results));
        }
예제 #7
0
 public IEnumerable <GameResult> SelectData()
 {
     return(_resultsService.GetResults());
 }
 public IActionResult GetAll()
 {
     _logger.LogInformation("Getting list of results.");
     return(Ok(_operationService.GetResults()));
 }