public IActionResult Index(int delegateId)
        {
            var centreId     = User.GetCentreId();
            var delegateUser = userService.GetUsersById(null, delegateId).delegateUser;

            if (delegateUser == null || delegateUser.CentreId != centreId)
            {
                return(NotFound());
            }

            var jobGroups = jobGroupsDataService.GetJobGroupsAlphabetical().ToList();

            var customPrompts =
                promptsService.GetEditDelegateRegistrationPromptViewModelsForCentre(delegateUser, centreId);
            var model = new EditDelegateViewModel(delegateUser, jobGroups, customPrompts);

            return(View(model));
        }
        public void GetEditDelegateRegistrationPromptViewModelsForCentre_returns_populated_list()
        {
            // Given
            var registrationPrompt1       = PromptsTestHelper.GetDefaultCentreRegistrationPrompt(1, options: "Clinical\r\nNon-Clinical");
            var registrationPrompt2       = PromptsTestHelper.GetDefaultCentreRegistrationPrompt(2);
            var centreRegistrationPrompts = PromptsTestHelper.GetDefaultCentreRegistrationPrompts(
                new List <CentreRegistrationPrompt> {
                registrationPrompt1, registrationPrompt2
            },
                1
                );

            A.CallTo(() => centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(1))
            .Returns(centreRegistrationPrompts);

            // When
            var result =
                promptsService.GetEditDelegateRegistrationPromptViewModelsForCentre(
                    1,
                    Answer1,
                    Answer2,
                    null,
                    null,
                    null,
                    null
                    );

            // Then
            using (new AssertionScope())
            {
                result.Count.Should().Be(2);

                result[0].PromptNumber.Should().Be(1);
                result[0].Options.Count().Should().Be(2);
                result[0].Options.First().Value.Should().BeEquivalentTo("Clinical");

                result[1].PromptNumber.Should().Be(2);
                result[1].Options.Count().Should().Be(0);
            }
        }
 private IEnumerable <EditDelegateRegistrationPromptViewModel> GetEditDelegateRegistrationPromptViewModelsFromModel(
     LearnerInformationViewModel model,
     int centreId
     )
 {
     return(promptsService.GetEditDelegateRegistrationPromptViewModelsForCentre(
                centreId,
                model.Answer1,
                model.Answer2,
                model.Answer3,
                model.Answer4,
                model.Answer5,
                model.Answer6
                ));
 }
예제 #4
0
        public IActionResult EditDetails(DlsSubApplication dlsSubApplication)
        {
            var userAdminId    = User.GetAdminId();
            var userDelegateId = User.GetCandidateId();

            var(adminUser, delegateUser) = userService.GetUsersById(userAdminId, userDelegateId);

            var jobGroups     = jobGroupsDataService.GetJobGroupsAlphabetical().ToList();
            var customPrompts =
                promptsService.GetEditDelegateRegistrationPromptViewModelsForCentre(delegateUser, User.GetCentreId());

            var model = new MyAccountEditDetailsViewModel(
                adminUser,
                delegateUser,
                jobGroups,
                customPrompts,
                dlsSubApplication
                );

            return(View(model));
        }