diff --git a/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs b/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs index 9b4d0c68be..8511437b4f 100644 --- a/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs +++ b/DigitalLearningSolutions.Data.Tests/Services/RegistrationServiceTests.cs @@ -346,5 +346,35 @@ public void Error_in_RegisterCentreManager_fails_fast() A.CallTo(() => centresDataService.SetCentreAutoRegistered(testRegistrationModel.Centre)) .MustNotHaveHappened(); } + + [Test] + public void RegisterDelegateByCentre_sets_password_if_passwordHash_not_null() + { + // Given + var model = new DelegateRegistrationModel("firstName", "lastName", "email", 0, 0, PasswordHash); + A.CallTo(() => registrationDataService.RegisterDelegateByCentre(model)).Returns(NewCandidateNumber); + + // When + registrationService.RegisterDelegateByCentre(model); + + // Then + A.CallTo(() => registrationDataService.RegisterDelegateByCentre(model)).MustHaveHappened(1, Times.Exactly); + A.CallTo(() => passwordDataService.SetPasswordByCandidateNumber(NewCandidateNumber, PasswordHash)).MustHaveHappened(1, Times.Exactly); + } + + [Test] + public void RegisterDelegateByCentre_does_not_set_password_if_passwordHash_is_null() + { + // Given + var model = new DelegateRegistrationModel("firstName", "lastName", "email", 0, 0, null); + A.CallTo(() => registrationDataService.RegisterDelegateByCentre(model)).Returns(NewCandidateNumber); + + // When + registrationService.RegisterDelegateByCentre(model); + + // Then + A.CallTo(() => registrationDataService.RegisterDelegateByCentre(model)).MustHaveHappened(1, Times.Exactly); + A.CallTo(() => passwordDataService.SetPasswordByCandidateNumber(A._, A._)).MustNotHaveHappened(); + } } } diff --git a/DigitalLearningSolutions.Data/DataServices/RegistrationDataService.cs b/DigitalLearningSolutions.Data/DataServices/RegistrationDataService.cs index eabc54dc3e..b90a69b955 100644 --- a/DigitalLearningSolutions.Data/DataServices/RegistrationDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/RegistrationDataService.cs @@ -9,6 +9,7 @@ public interface IRegistrationDataService { string RegisterDelegate(DelegateRegistrationModel delegateRegistrationModel); + string RegisterDelegateByCentre(DelegateRegistrationModel delegateRegistrationModel); int RegisterCentreManagerAdmin(RegistrationModel registrationModel); } @@ -53,6 +54,38 @@ public string RegisterDelegate(DelegateRegistrationModel delegateRegistrationMod return candidateNumber; } + public string RegisterDelegateByCentre(DelegateRegistrationModel delegateRegistrationModel) + { + var values = new + { + delegateRegistrationModel.FirstName, + delegateRegistrationModel.LastName, + delegateRegistrationModel.Email, + CentreID = delegateRegistrationModel.Centre, + JobGroupID = delegateRegistrationModel.JobGroup, + Active = 1, + Approved = 1, + delegateRegistrationModel.Answer1, + delegateRegistrationModel.Answer2, + delegateRegistrationModel.Answer3, + delegateRegistrationModel.Answer4, + delegateRegistrationModel.Answer5, + delegateRegistrationModel.Answer6, + AliasID = delegateRegistrationModel.AliasId, + ExternalReg = 0, + SelfReg = 0, + delegateRegistrationModel.NotifyDate, + Bulk = 0 + }; + + var candidateNumber = connection.QueryFirstOrDefault( + "uspSaveNewCandidate_V10", + values, + commandType: CommandType.StoredProcedure); + + return candidateNumber; + } + public int RegisterCentreManagerAdmin(RegistrationModel registrationModel) { var values = new diff --git a/DigitalLearningSolutions.Data/Models/Register/DelegateRegistrationModel.cs b/DigitalLearningSolutions.Data/Models/Register/DelegateRegistrationModel.cs index 3d2cdc736e..071cc70148 100644 --- a/DigitalLearningSolutions.Data/Models/Register/DelegateRegistrationModel.cs +++ b/DigitalLearningSolutions.Data/Models/Register/DelegateRegistrationModel.cs @@ -1,5 +1,7 @@ namespace DigitalLearningSolutions.Data.Models.Register { + using System; + public class DelegateRegistrationModel : RegistrationModel { public DelegateRegistrationModel( @@ -8,13 +10,16 @@ public DelegateRegistrationModel( string email, int centre, int jobGroup, - string passwordHash, + string? passwordHash, string? answer1, string? answer2, string? answer3, string? answer4, string? answer5, - string? answer6) : base(firstName, lastName, email, centre, jobGroup, passwordHash) + string? answer6, + string? aliasId = null, + DateTime? notifyDate = null + ) : base(firstName, lastName, email, centre, jobGroup, passwordHash) { Answer1 = answer1; Answer2 = answer2; @@ -22,6 +27,8 @@ public DelegateRegistrationModel( Answer4 = answer4; Answer5 = answer5; Answer6 = answer6; + AliasId = aliasId; + NotifyDate = notifyDate; } public DelegateRegistrationModel( @@ -30,7 +37,7 @@ public DelegateRegistrationModel( string email, int centre, int jobGroup, - string passwordHash + string? passwordHash ) : base(firstName, lastName, email, centre, jobGroup, passwordHash) { } public string? Answer1 { get; set; } @@ -44,5 +51,9 @@ string passwordHash public string? Answer5 { get; set; } public string? Answer6 { get; set; } + + public string? AliasId { get; set; } + + public DateTime? NotifyDate { get; set; } } } diff --git a/DigitalLearningSolutions.Data/Models/Register/RegistrationModel.cs b/DigitalLearningSolutions.Data/Models/Register/RegistrationModel.cs index 6d745db4e2..b0db835fd1 100644 --- a/DigitalLearningSolutions.Data/Models/Register/RegistrationModel.cs +++ b/DigitalLearningSolutions.Data/Models/Register/RegistrationModel.cs @@ -8,7 +8,7 @@ public RegistrationModel( string email, int centre, int jobGroup, - string passwordHash + string? passwordHash ) { FirstName = firstName; @@ -30,7 +30,7 @@ string passwordHash public int JobGroup { get; set; } - public string PasswordHash { get; set; } + public string? PasswordHash { get; set; } public bool Approved { get; set; } } diff --git a/DigitalLearningSolutions.Data/Services/RegistrationService.cs b/DigitalLearningSolutions.Data/Services/RegistrationService.cs index 48f6db1fdc..e1fdd74027 100644 --- a/DigitalLearningSolutions.Data/Services/RegistrationService.cs +++ b/DigitalLearningSolutions.Data/Services/RegistrationService.cs @@ -17,6 +17,8 @@ public interface IRegistrationService bool refactoredTrackingSystemEnabled ); + string RegisterDelegateByCentre(DelegateRegistrationModel delegateRegistrationModel); + void RegisterCentreManager(RegistrationModel registrationModel); } @@ -63,7 +65,7 @@ bool refactoredTrackingSystemEnabled passwordDataService.SetPasswordByCandidateNumber( candidateNumber, - delegateRegistrationModel.PasswordHash + delegateRegistrationModel.PasswordHash! ); if (!delegateRegistrationModel.Approved) { @@ -81,6 +83,25 @@ bool refactoredTrackingSystemEnabled return (candidateNumber, delegateRegistrationModel.Approved); } + public string RegisterDelegateByCentre(DelegateRegistrationModel delegateRegistrationModel) + { + var candidateNumber = registrationDataService.RegisterDelegateByCentre(delegateRegistrationModel); + if (candidateNumber == "-1" || candidateNumber == "-4") + { + return candidateNumber; + } + + if (delegateRegistrationModel.PasswordHash != null) + { + passwordDataService.SetPasswordByCandidateNumber( + candidateNumber, + delegateRegistrationModel.PasswordHash + ); + } + + return candidateNumber; + } + public void RegisterCentreManager(RegistrationModel registrationModel) { using var transaction = new TransactionScope(); @@ -102,7 +123,7 @@ private void CreateDelegateAccountForAdmin(RegistrationModel registrationModel) registrationModel.Email, registrationModel.Centre, registrationModel.JobGroup, - registrationModel.PasswordHash + registrationModel.PasswordHash! ) { Approved = true }; var candidateNumber = registrationDataService.RegisterDelegate(delegateRegistrationModel); @@ -115,7 +136,7 @@ private void CreateDelegateAccountForAdmin(RegistrationModel registrationModel) passwordDataService.SetPasswordByCandidateNumber( candidateNumber, - delegateRegistrationModel.PasswordHash + delegateRegistrationModel.PasswordHash! ); } diff --git a/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/RegistrationJourneyAccessibilityTests.cs b/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/RegistrationJourneyAccessibilityTests.cs index dee9d2edd2..44487ff557 100644 --- a/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/RegistrationJourneyAccessibilityTests.cs +++ b/DigitalLearningSolutions.Web.AutomatedUiTests/AccessibilityTests/RegistrationJourneyAccessibilityTests.cs @@ -2,8 +2,6 @@ { using DigitalLearningSolutions.Web.AutomatedUiTests.TestHelpers; using FluentAssertions; - using OpenQA.Selenium; - using OpenQA.Selenium.Support.UI; using Selenium.Axe; using Xunit; @@ -45,5 +43,83 @@ public void Registration_journey_has_no_accessibility_errors() passwordResult.Violations.Should().BeEmpty(); summaryResult.Violations.Should().BeEmpty(); } + + [Fact] + public void Registration_by_centre_journey_with_send_email_has_no_accessibility_errors() + { + // given + Driver.LogUserInAsAdminAndDelegate(BaseUrl); + const string registerUrl = "/TrackingSystem/Delegates/Register"; + + // when + Driver.Navigate().GoToUrl(BaseUrl + registerUrl); + var registerResult = new AxeBuilder(Driver).Analyze(); + Driver.FillTextInput("FirstName", "Test"); + Driver.FillTextInput("LastName", "User"); + Driver.FillTextInput("Email", "candidate@test.com"); + Driver.FillTextInput("Alias", "candid8"); + Driver.SubmitForm(); + + var learnerInformationResult = new AxeBuilder(Driver).Analyze(); + Driver.SelectDropdownItemValue("Answer1", "Principal Relationship Manager"); + Driver.FillTextInput("Answer2", "A Person"); + Driver.SelectDropdownItemValue("JobGroup", "1"); + Driver.SubmitForm(); + + var welcomeEmailResult = new AxeBuilder(Driver).Analyze(); + Driver.SetCheckboxState("ShouldSendEmail", true); + Driver.FillTextInput("Day", "14"); + Driver.FillTextInput("Month", "7"); + Driver.FillTextInput("Year", "2222"); + Driver.SubmitForm(); + + var summaryResult = new AxeBuilder(Driver).Analyze(); + + // then + registerResult.Violations.Should().BeEmpty(); + learnerInformationResult.Violations.Should().BeEmpty(); + welcomeEmailResult.Violations.Should().BeEmpty(); + summaryResult.Violations.Should().BeEmpty(); + } + + [Fact] + public void Registration_by_centre_journey_with_set_password_has_no_accessibility_errors() + { + // given + Driver.LogUserInAsAdminAndDelegate(BaseUrl); + const string registerUrl = "/TrackingSystem/Delegates/Register"; + + // when + Driver.Navigate().GoToUrl(BaseUrl + registerUrl); + var registerResult = new AxeBuilder(Driver).Analyze(); + Driver.FillTextInput("FirstName", "Test"); + Driver.FillTextInput("LastName", "User"); + Driver.FillTextInput("Email", "candidate@test.com"); + Driver.FillTextInput("Alias", "candid8"); + Driver.SubmitForm(); + + var learnerInformationResult = new AxeBuilder(Driver).Analyze(); + Driver.SelectDropdownItemValue("Answer1", "Principal Relationship Manager"); + Driver.FillTextInput("Answer2", "A Person"); + Driver.SelectDropdownItemValue("JobGroup", "1"); + Driver.SubmitForm(); + + var welcomeEmailResult = new AxeBuilder(Driver).Analyze(); + Driver.SetCheckboxState("ShouldSendEmail", false); + Driver.SubmitForm(); + + var passwordResult = new AxeBuilder(Driver).Analyze(); + Driver.FillTextInput("Password", "password!1"); + Driver.SubmitForm(); + + var summaryResult = new AxeBuilder(Driver).Analyze(); + + // then + registerResult.Violations.Should().BeEmpty(); + learnerInformationResult.Violations.Should().BeEmpty(); + welcomeEmailResult.Violations.Should().BeEmpty(); + passwordResult.Violations.Should().BeEmpty(); + summaryResult.Violations.Should().BeEmpty(); + } } } diff --git a/DigitalLearningSolutions.Web.AutomatedUiTests/TestHelpers/DriverHelper.cs b/DigitalLearningSolutions.Web.AutomatedUiTests/TestHelpers/DriverHelper.cs index ad78d507f2..90d482d9b6 100644 --- a/DigitalLearningSolutions.Web.AutomatedUiTests/TestHelpers/DriverHelper.cs +++ b/DigitalLearningSolutions.Web.AutomatedUiTests/TestHelpers/DriverHelper.cs @@ -31,6 +31,15 @@ public static void SelectDropdownItemValue(this IWebDriver driver, string dropdo dropdown.SelectByValue(selectedValue); } + public static void SetCheckboxState(this IWebDriver driver, string inputId, bool checkState) + { + var answer = driver.FindElement(By.Id(inputId)); + if (answer.Selected != checkState) + { + answer.Click(); + } + } + public static void SubmitForm(this IWebDriver driver) { var selectPromptForm = driver.FindElement(By.TagName("form")); diff --git a/DigitalLearningSolutions.Web.Tests/Controllers/Register/RegisterDelegateByCentreControllerTests.cs b/DigitalLearningSolutions.Web.Tests/Controllers/Register/RegisterDelegateByCentreControllerTests.cs index 752b4f1480..539aea67cd 100644 --- a/DigitalLearningSolutions.Web.Tests/Controllers/Register/RegisterDelegateByCentreControllerTests.cs +++ b/DigitalLearningSolutions.Web.Tests/Controllers/Register/RegisterDelegateByCentreControllerTests.cs @@ -1,7 +1,9 @@ namespace DigitalLearningSolutions.Web.Tests.Controllers.Register { + using System; using System.Collections.Generic; using DigitalLearningSolutions.Data.DataServices; + using DigitalLearningSolutions.Data.Models.Register; using DigitalLearningSolutions.Data.Models.User; using DigitalLearningSolutions.Data.Services; using DigitalLearningSolutions.Data.Tests.TestHelpers; @@ -10,19 +12,24 @@ using DigitalLearningSolutions.Web.Helpers; using DigitalLearningSolutions.Web.Models; using DigitalLearningSolutions.Web.Tests.ControllerHelpers; + using DigitalLearningSolutions.Web.ViewModels.Common; using DigitalLearningSolutions.Web.ViewModels.Register; + using DigitalLearningSolutions.Web.ViewModels.Register.RegisterDelegateByCentre; using FakeItEasy; + using FluentAssertions; using FluentAssertions.AspNetCore.Mvc; using NUnit.Framework; + using SummaryViewModel = DigitalLearningSolutions.Web.ViewModels.Register.RegisterDelegateByCentre.SummaryViewModel; public class RegisterDelegateByCentreControllerTests { private RegisterDelegateByCentreController controller = null!; + private ICryptoService cryptoService = null!; private CustomPromptHelper customPromptHelper = null!; private IJobGroupsDataService jobGroupsDataService = null!; + private IRegistrationService registrationService = null!; private IUserDataService userDataService = null!; private IUserService userService = null!; - private ICryptoService cryptoService = null!; [SetUp] public void Setup() @@ -32,12 +39,14 @@ public void Setup() userDataService = A.Fake(); customPromptHelper = A.Fake(); cryptoService = A.Fake(); + registrationService = A.Fake(); controller = new RegisterDelegateByCentreController( jobGroupsDataService, userService, customPromptHelper, cryptoService, - userDataService + userDataService, + registrationService ) .WithDefaultContext() .WithMockTempData(); @@ -142,5 +151,170 @@ public void PersonalInformationPost_with_duplicate_alias_for_different_centre_is A.CallTo(() => userDataService.GetAllDelegateUsersByUsername(duplicateAlias)).MustHaveHappened(); result.Should().BeRedirectToActionResult().WithActionName("LearnerInformation"); } + + [Test] + public void PersonalInformationPost_updates_tempdata_correctly() + { + // Given + const string firstName = "Test"; + const string lastName = "User"; + const string email = "test@email.com"; + const string alias = "testuser"; + + controller.TempData.Set(new DelegateRegistrationByCentreData()); + var model = new PersonalInformationViewModel + { + FirstName = firstName, + LastName = lastName, + Email = email, + Alias = alias + }; + + // When + controller.PersonalInformation(model); + + // Then + var data = controller.TempData.Peek()!; + data.FirstName.Should().Be(firstName); + data.LastName.Should().Be(lastName); + data.Email.Should().Be(email); + data.Alias.Should().Be(alias); + } + + [Test] + public void LearnerInformationPost_updates_tempdata_correctly() + { + // Given + const int jobGroupId = 3; + const string answer1 = "answer1"; + const string answer2 = "answer2"; + const string answer3 = "answer3"; + const string answer4 = "answer4"; + const string answer5 = "answer5"; + const string answer6 = "answer6"; + + controller.TempData.Set(new DelegateRegistrationByCentreData { Centre = 1 }); + var model = new LearnerInformationViewModel + { + JobGroup = jobGroupId, + Answer1 = answer1, + Answer2 = answer2, + Answer3 = answer3, + Answer4 = answer4, + Answer5 = answer5, + Answer6 = answer6 + }; + + // When + controller.LearnerInformation(model); + + // Then + var data = controller.TempData.Peek()!; + data.JobGroup.Should().Be(jobGroupId); + data.Answer1.Should().Be(answer1); + data.Answer2.Should().Be(answer2); + data.Answer3.Should().Be(answer3); + data.Answer4.Should().Be(answer4); + data.Answer5.Should().Be(answer5); + data.Answer6.Should().Be(answer6); + } + + [Test] + public void WelcomeEmailPost_with_ShouldSendEmail_false_updates_tempdata_correctly() + { + // Given + controller.TempData.Set(new DelegateRegistrationByCentreData()); + var model = new WelcomeEmailViewModel { ShouldSendEmail = false, Day = 7, Month = 7, Year = 2200 }; + + // When + controller.WelcomeEmail(model); + + // Then + var data = controller.TempData.Peek()!; + data.ShouldSendEmail.Should().BeFalse(); + data.WelcomeEmailDate.Should().BeNull(); + } + + [Test] + public void WelcomeEmailPost_with_ShouldSendEmail_true_updates_tempdata_correctly() + { + // Given + controller.TempData.Set(new DelegateRegistrationByCentreData { PasswordHash = "hash" }); + var date = new DateTime(2200, 7, 7); + var model = new WelcomeEmailViewModel + { ShouldSendEmail = true, Day = date.Day, Month = date.Month, Year = date.Year }; + + // When + controller.WelcomeEmail(model); + + // Then + var data = controller.TempData.Peek()!; + data.ShouldSendEmail.Should().BeTrue(); + data.WelcomeEmailDate.Should().Be(date); + data.IsPasswordSet.Should().BeFalse(); + data.PasswordHash.Should().BeNull(); + } + + [Test] + public void PasswordPost_with_no_password_updates_tempdata_correctly() + { + // Given + controller.TempData.Set(new DelegateRegistrationByCentreData()); + var model = new PasswordViewModel { Password = null }; + A.CallTo(() => cryptoService.GetPasswordHash(A._)).Returns("hash"); + + // When + controller.Password(model); + + // Then + A.CallTo(() => cryptoService.GetPasswordHash(A._)).MustNotHaveHappened(); + var data = controller.TempData.Peek()!; + data.PasswordHash.Should().BeNull(); + } + + [Test] + public void PasswordPost_with_password_updates_tempdata_correctly() + { + // Given + controller.TempData.Set(new DelegateRegistrationByCentreData()); + var model = new PasswordViewModel { Password = "pwd" }; + const string passwordHash = "hash"; + A.CallTo(() => cryptoService.GetPasswordHash(A._)).Returns(passwordHash); + + // When + controller.Password(model); + + // Then + A.CallTo(() => cryptoService.GetPasswordHash(A._)).MustHaveHappened(1, Times.Exactly); + var data = controller.TempData.Peek()!; + data.PasswordHash.Should().Be(passwordHash); + } + + [Test] + public void SummaryPost_updates_tempdata_correctly() + { + // Given + const string sampleDelegateNumber = "CR7"; + var data = new DelegateRegistrationByCentreData + { + FirstName = "Test", LastName = "User", Email = "test@mail.com", Centre = 5, JobGroup = 0, + WelcomeEmailDate = new DateTime(2200, 7, 7) + }; + controller.TempData.Set(data); + var model = new SummaryViewModel(); + A.CallTo(() => registrationService.RegisterDelegateByCentre(A._)) + .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); + } } } diff --git a/DigitalLearningSolutions.Web/Controllers/Register/RegisterDelegateByCentreController.cs b/DigitalLearningSolutions.Web/Controllers/Register/RegisterDelegateByCentreController.cs index 0ee764206e..f3b216cdd3 100644 --- a/DigitalLearningSolutions.Web/Controllers/Register/RegisterDelegateByCentreController.cs +++ b/DigitalLearningSolutions.Web/Controllers/Register/RegisterDelegateByCentreController.cs @@ -17,6 +17,8 @@ namespace DigitalLearningSolutions.Web.Controllers.Register using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.FeatureManagement.Mvc; + using ConfirmationViewModel = + DigitalLearningSolutions.Web.ViewModels.Register.RegisterDelegateByCentre.ConfirmationViewModel; using SummaryViewModel = DigitalLearningSolutions.Web.ViewModels.Register.RegisterDelegateByCentre.SummaryViewModel; [FeatureGate(FeatureFlags.RefactoredTrackingSystem)] @@ -28,6 +30,7 @@ public class RegisterDelegateByCentreController : Controller private readonly ICryptoService cryptoService; private readonly CustomPromptHelper customPromptHelper; private readonly IJobGroupsDataService jobGroupsDataService; + private readonly IRegistrationService registrationService; private readonly IUserDataService userDataService; private readonly IUserService userService; @@ -36,13 +39,15 @@ public RegisterDelegateByCentreController( IUserService userService, CustomPromptHelper customPromptHelper, ICryptoService cryptoService, - IUserDataService userDataService + IUserDataService userDataService, + IRegistrationService registrationService ) { this.jobGroupsDataService = jobGroupsDataService; this.userService = userService; this.customPromptHelper = customPromptHelper; this.userDataService = userDataService; + this.registrationService = registrationService; this.cryptoService = cryptoService; } @@ -203,7 +208,42 @@ public IActionResult Summary() [HttpPost] public IActionResult Summary(SummaryViewModel model) { - return new OkResult(); + var data = TempData.Peek()!; + + var candidateNumber = + registrationService.RegisterDelegateByCentre( + RegistrationMappingHelper.MapToDelegateRegistrationModel(data) + ); + + switch (candidateNumber) + { + case "-1": + return StatusCode(500); + case "-4": + return RedirectToAction("Index"); + } + + TempData.Clear(); + TempData.Add("delegateNumber", candidateNumber); + TempData.Add("emailSent", data.ShouldSendEmail); + TempData.Add("passwordSet", data.IsPasswordSet); + return RedirectToAction("Confirmation"); + } + + [HttpGet] + public IActionResult Confirmation() + { + var delegateNumber = (string?)TempData.Peek("delegateNumber"); + var emailSent = (bool)TempData.Peek("emailSent"); + var passwordSet = (bool)TempData.Peek("passwordSet"); + TempData.Clear(); + if (delegateNumber == null) + { + return RedirectToAction("Index"); + } + + var viewModel = new ConfirmationViewModel(delegateNumber, emailSent, passwordSet); + return View(viewModel); } private void SetCentreDelegateRegistrationData(int centreId) diff --git a/DigitalLearningSolutions.Web/Helpers/RegistrationMappingHelper.cs b/DigitalLearningSolutions.Web/Helpers/RegistrationMappingHelper.cs index 2e27a109a8..f5d45b0132 100644 --- a/DigitalLearningSolutions.Web/Helpers/RegistrationMappingHelper.cs +++ b/DigitalLearningSolutions.Web/Helpers/RegistrationMappingHelper.cs @@ -34,5 +34,25 @@ public static DelegateRegistrationModel MapToDelegateRegistrationModel(DelegateR data.Answer6 ); } + + public static DelegateRegistrationModel MapToDelegateRegistrationModel(DelegateRegistrationByCentreData data) + { + return new DelegateRegistrationModel( + data.FirstName!, + data.LastName!, + data.Email!, + data.Centre!.Value, + data.JobGroup!.Value, + data.PasswordHash, + data.Answer1, + data.Answer2, + data.Answer3, + data.Answer4, + data.Answer5, + data.Answer6, + data.Alias, + data.WelcomeEmailDate + ); + } } } diff --git a/DigitalLearningSolutions.Web/ViewModels/Register/RegisterDelegateByCentre/ConfirmationViewModel.cs b/DigitalLearningSolutions.Web/ViewModels/Register/RegisterDelegateByCentre/ConfirmationViewModel.cs new file mode 100644 index 0000000000..2dbc04b332 --- /dev/null +++ b/DigitalLearningSolutions.Web/ViewModels/Register/RegisterDelegateByCentre/ConfirmationViewModel.cs @@ -0,0 +1,16 @@ +namespace DigitalLearningSolutions.Web.ViewModels.Register.RegisterDelegateByCentre +{ + public class ConfirmationViewModel + { + public ConfirmationViewModel(string delegateNumber, bool emailWillBeSent, bool passwordSet) + { + DelegateNumber = delegateNumber; + EmailWillBeSent = emailWillBeSent; + PasswordSet = passwordSet; + } + + public string DelegateNumber { get; set; } + public bool EmailWillBeSent { get; set; } + public bool PasswordSet { get; set; } + } +} diff --git a/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Confirmation.cshtml b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Confirmation.cshtml new file mode 100644 index 0000000000..a9104ee68d --- /dev/null +++ b/DigitalLearningSolutions.Web/Views/RegisterDelegateByCentre/Confirmation.cshtml @@ -0,0 +1,43 @@ +@inject IConfiguration Configuration +@using DigitalLearningSolutions.Web.ViewModels.Register.RegisterDelegateByCentre +@using Microsoft.Extensions.Configuration +@model ConfirmationViewModel + +@{ + ViewData["Title"] = "Register Delegate - Confirmation"; + ViewData["Application"] = "Tracking System"; + ViewData["HeaderPath"] = $"{Configuration["AppRootPath"]}/TrackingSystem/Centre/Dashboard"; + ViewData["HeaderPathName"] = "Tracking System"; +} + +@section NavMenuItems { + +} + +
+
+

+ Delegate registration complete +

+ @if (Model.EmailWillBeSent) { +

+ A welcome message will be sent to the email address provided, on the date specified, inviting the delegate to set their password and confirm their registration. +

+ } else { + if (Model.PasswordSet) { +

+ You should contact the delegate to inform them of their login details and recommend that they change their password using the My account interface after login. +

+ } else { +

+ The delegate has been registered but no welcome email has been sent. You can send the welcome email at a later date from the All Delegates interface using the Send Welcome Emails button. +

+ } + } +
+ Information: +

Delegate number @Model.DelegateNumber

+
+ +
+