예제 #1
0
        public void SummaryPost_updates_tempdata_correctly()
        {
            // Given
            const string sampleDelegateNumber = "CR7";
            var          data = new DelegateRegistrationByCentreData
            {
                FirstName        = "Test", LastName = "User", Email = "*****@*****.**", Centre = 5, JobGroup = 0,
                WelcomeEmailDate = new DateTime(2200, 7, 7)
            };

            controller.TempData.Set(data);
            var model = new SummaryViewModel();

            A.CallTo(() => registrationService.RegisterDelegateByCentre(A <DelegateRegistrationModel> ._, A <string> ._))
            .Returns(sampleDelegateNumber);

            // When
            controller.Summary(model);

            // Then
            var delegateNumber = (string?)controller.TempData.Peek("delegateNumber");
            var emailSent      = (bool)controller.TempData.Peek("emailSent");
            var passwordSet    = (bool)controller.TempData.Peek("passwordSet");

            delegateNumber.Should().Be(sampleDelegateNumber);
            emailSent.Should().Be(data.ShouldSendEmail);
            passwordSet.Should().Be(data.IsPasswordSet);
        }
        public IActionResult Summary(SummaryViewModel model)
        {
            var data    = TempData.Peek <DelegateRegistrationByCentreData>() !;
            var baseUrl = config.GetAppRootPath();

            try
            {
                var candidateNumber = registrationService.RegisterDelegateByCentre(
                    RegistrationMappingHelper.MapCentreRegistrationToDelegateRegistrationModel(data),
                    baseUrl
                    );

                TempData.Clear();
                TempData.Add("delegateNumber", candidateNumber);
                TempData.Add("emailSent", data.ShouldSendEmail);
                TempData.Add("passwordSet", data.IsPasswordSet);
                return(RedirectToAction("Confirmation"));
            }
            catch (DelegateCreationFailedException e)
            {
                var error = e.Error;

                if (error.Equals(DelegateCreationError.UnexpectedError))
                {
                    return(new StatusCodeResult(500));
                }

                if (error.Equals(DelegateCreationError.EmailAlreadyInUse))
                {
                    return(RedirectToAction("Index"));
                }

                return(new StatusCodeResult(500));
            }
        }
예제 #3
0
        public IActionResult Summary()
        {
            var data      = TempData.Peek <DelegateRegistrationByCentreData>() !;
            var viewModel = new SummaryViewModel(data);

            PopulateSummaryExtraFields(viewModel, data);
            return(View(viewModel));
        }
예제 #4
0
 private void PopulateSummaryExtraFields(SummaryViewModel model, DelegateRegistrationData data)
 {
     model.JobGroup     = jobGroupsDataService.GetJobGroupName((int)data.JobGroup !);
     model.CustomFields = GetCustomFieldsFromData(data);
 }