Esempio n. 1
0
        public async Task <IActionResult> LaunchLearningResource(int resourceReferenceId)
        {
            var delegateId = User.GetCandidateIdKnownNotNull();

            actionPlanService.UpdateActionPlanResourcesLastAccessedDateIfPresent(resourceReferenceId, delegateId);

            var delegateUser = userService.GetDelegateUserById(delegateId);

            var(resource, apiIsAccessible) =
                await learningHubResourceService.GetResourceByReferenceIdAndPopulateDeletedDetailsFromDatabase(
                    resourceReferenceId
                    );

            if (resource == null || resource.AbsentInLearningHub)
            {
                return(NotFound());
            }

            if (delegateUser !.HasDismissedLhLoginWarning)
            {
                return(RedirectToAction("ViewResource", "SignpostingSso", new { resourceReferenceId }));
            }

            var learningHubAccountIsLinked = userService.DelegateUserLearningHubAccountIsLinked(delegateId);

            var model = new LearningHubLoginWarningViewModel(
                resource,
                learningHubAccountIsLinked,
                apiIsAccessible
                );

            return(View("LearningHubLoginWarning", model));
        }
Esempio n. 2
0
        public async Task LaunchLearningResource_shows_warning_if_not_dismissed()
        {
            // When
            var result = await controller.LaunchLearningResource(ResourceReferenceId);

            // Then
            result.Should().BeViewResult().WithViewName("LearningHubLoginWarning");
            A.CallTo(() => userService.DelegateUserLearningHubAccountIsLinked(A <int> ._)).MustHaveHappenedOnceExactly();
            A.CallTo(() => learningHubResourceService.GetResourceByReferenceIdAndPopulateDeletedDetailsFromDatabase(A <int> ._)).MustHaveHappenedOnceExactly();
        }