diff --git a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj index e5fff6967..48d14054a 100644 --- a/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj +++ b/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj @@ -83,7 +83,7 @@ - + diff --git a/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj b/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj index 536fb9b3a..ec884b479 100644 --- a/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj +++ b/LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj @@ -11,6 +11,7 @@ + diff --git a/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs b/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs index d1dadb902..f1c3e1758 100644 --- a/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs @@ -131,8 +131,284 @@ public async Task Index(string returnUrl = null, bool? checkDetai } } - var userProfileSummary = await this.userService.GetUserProfileSummaryAsync(); - return this.View("Index", userProfileSummary); + var userPersonalDetails = await this.userService.GetMyAccountPersonalDetailsAsync(); + return this.View("Index", userPersonalDetails); + } + + /// + /// MyEmploymentDetails. + /// + /// IActionResult. + [HttpGet] + [Route("myaccount-employement")] + public async Task MyEmploymentDetails() + { + var employmentDetails = await this.userService.GetMyEmploymentDetailsAsync(); + return this.View("MyEmployment", employmentDetails); + } + + /// + /// User profile actions. + /// + /// The redirect back url. + /// Whether to check account details. + /// IActionResult. + [HttpGet] + [Route("myaccount-security")] + public async Task MyAccountSecurity(string returnUrl = null, bool? checkDetails = false) + { + var securityDetails = await this.userService.GetMyAccountSecurityDetailsAsync(); + return this.View("MyAccountSecurity", securityDetails); + } + + /// + /// ChangePersonalDetails. + /// + /// ActionResult. + [HttpGet] + [Route("myaccount/ChangePersonalDetails")] + public async Task ChangePersonalDetails() + { + var userPersonalDetails = await this.userService.GetMyAccountPersonalDetailsAsync(); + return this.View("ChangePersonalDetails", userPersonalDetails); + } + + /// + /// To Update first name. + /// + /// model. + /// ActionResult. + [HttpPost] + public async Task UpdatePersonalDetails(MyAccountPersonalDetailsViewModel model) + { + if (!this.ModelState.IsValid) + { + return this.View("ChangePersonalDetails", model); + } + + bool isSamePrimaryEmailPendingforValidate = await this.userService.CheckSamePrimaryemailIsPendingToValidate(model.SecondaryEmailAddress); + if (isSamePrimaryEmailPendingforValidate) + { + this.ModelState.AddModelError(string.Empty, CommonValidationErrorMessages.SecondaryEmailShouldNotBeSame); + return this.View("ChangePersonalDetails", model); + } + + await this.userService.UpdateMyAccountPersonalDetailsAsync(this.CurrentUserId, model); + await this.MyAccountUpdatePrimaryEmail(model.PrimaryEmailAddress); + this.ViewBag.SuccessMessage = CommonValidationErrorMessages.PersonalDetailsSuccessMessage; + this.ViewBag.MyAction = "Index"; + return this.View("SuccessMessageMyAccount"); + } + + /// + /// ChangeLocation. + /// + /// model. + /// formSubmission. + /// ActionResult. + [HttpGet] + [Route("myaccount/ChangeLocation")] + public async Task ChangeLocation([FromQuery] MyAccountLocationViewModel model, bool formSubmission = false) + { + var userLocationViewModel = await this.userService.GetMyAccountLocationDetailsAsync(); + var allUKcountries = await this.countryService.GetAllUKCountries(); + var allnonUKcountries = await this.countryService.GetAllNonUKCountries(); + var regions = await this.regionService.GetAllAsync(); + + List radio = new List(); + foreach (var country in allUKcountries) + { + var newradio = new RadiosItemViewModel(country.Id.ToString(), country.Name, false, country.Name); + radio.Add(newradio); + } + + if (allnonUKcountries.Any(v => v.Id == userLocationViewModel.SelectedCountryId)) + { + userLocationViewModel.SelectedOtherCountryId = userLocationViewModel.SelectedCountryId; + userLocationViewModel.SelectedCountryId = 0; + } + + userLocationViewModel.Country = radio; + userLocationViewModel.OtherCountryOptions = SelectListHelper.MapOptionsToSelectListItems(allnonUKcountries, userLocationViewModel.SelectedOtherCountryId); + + userLocationViewModel.RegionOptions = SelectListHelper.MapOptionsToSelectListItems(regions, userLocationViewModel.SelectedRegionId); + + if (formSubmission) + { + if (model?.SelectedCountryId == null) + { + this.ModelState.AddModelError(nameof(model.SelectedCountryId), CommonValidationErrorMessages.CountryRequired); + return this.View("MyAccountChangeLocation", userLocationViewModel); + } + else if (model.SelectedCountryId == 1 && model.SelectedRegionId == null) + { + userLocationViewModel.HasSelectedRegion = true; + this.ModelState.AddModelError(nameof(model.SelectedRegionId), CommonValidationErrorMessages.RegionRequired); + return this.View("MyAccountChangeLocation", userLocationViewModel); + } + else if (model.SelectedCountryId != 1) + { + model.SelectedRegionId = null; + } + + if (model?.SelectedCountryId == 0) + { + if (model.SelectedOtherCountryId != null && model.SelectedOtherCountryId > 0) + { + model.SelectedCountryId = model.SelectedOtherCountryId; + } + else + { + userLocationViewModel.HasSelectedOtherCountry = true; + this.ModelState.AddModelError(nameof(model.SelectedOtherCountryId), CommonValidationErrorMessages.CountryRequired); + return this.View("MyAccountChangeLocation", userLocationViewModel); + } + } + + if (this.ModelState.IsValid) + { + await this.userService.UpdateMyAccountLocationDetailsAsync(this.CurrentUserId, model); + this.ViewBag.SuccessMessage = CommonValidationErrorMessages.LocationDetailsSuccessMessage; + this.ViewBag.MyAction = "MyEmploymentDetails"; + return this.View("SuccessMessageMyAccount"); + } + } + + return this.View("MyAccountChangeLocation", userLocationViewModel); + } + + /// + /// SecurityQuestionsDetails. + /// + /// viewModel. + /// formSubmission. + /// ActionResult. + [HttpGet] + [Route("myaccount/MyAccountSecurityQuestionsDetails")] + public async Task MyAccountSecurityQuestionsDetails([FromQuery] MyAcountSecurityQuestionsViewModel viewModel, bool formSubmission = false) + { + MyAcountSecurityQuestionsViewModel securityViewModel = new MyAcountSecurityQuestionsViewModel(); + var result = await this.loginWizardService.GetSecurityQuestionsModel(this.CurrentUserId); + + if (result != null) + { + if (result.UserSecurityQuestions != null && result.UserSecurityQuestions.Count > 0) + { + securityViewModel.SelectedFirstQuestionId = result.UserSecurityQuestions[0].SecurityQuestionId; + securityViewModel.SelectedSecondQuestionId = result.UserSecurityQuestions.Count > 1 ? result.UserSecurityQuestions[1].SecurityQuestionId : 0; + securityViewModel.UserSecurityFirstQuestionId = result.UserSecurityQuestions[0].Id; + securityViewModel.UserSecuritySecondQuestionId = result.UserSecurityQuestions.Count > 1 ? result.UserSecurityQuestions[1].Id : 0; + } + + securityViewModel.FirstSecurityQuestions = SelectListHelper.MapSelectListWithSelection(result.SecurityQuestions, Convert.ToString(securityViewModel.SelectedFirstQuestionId)); + securityViewModel.SecondSecurityQuestions = SelectListHelper.MapSelectListWithSelection(result.SecurityQuestions, Convert.ToString(securityViewModel.SelectedSecondQuestionId)); + } + + if (formSubmission && viewModel != null) + { + if (viewModel.SelectedFirstQuestionId == viewModel.SelectedSecondQuestionId) + { + this.ModelState.AddModelError("DuplicateQuestion", CommonValidationErrorMessages.DuplicateQuestion); + return this.View("MyAccountSecurityQuestionsDetails", securityViewModel); + } + + if (viewModel.SelectedFirstQuestionId > 0) + { + this.ModelState.AddModelError(nameof(viewModel.SecurityFirstQuestionAnswerHash), CommonValidationErrorMessages.InvalidSecurityQuestionAnswer); + return this.View("MyAccountSecurityQuestionsDetails", securityViewModel); + } + + if (viewModel.SelectedSecondQuestionId > 0) + { + this.ModelState.AddModelError(nameof(viewModel.SecuritySecondQuestionAnswerHash), CommonValidationErrorMessages.InvalidSecurityQuestionAnswer); + return this.View("MyAccountSecurityQuestionsDetails", securityViewModel); + } + + if (this.ModelState.IsValid) + { + var userSecurityQuestions = new List + { + new UserSecurityQuestionViewModel + { + Id = securityViewModel.UserSecurityFirstQuestionId, + SecurityQuestionId = securityViewModel.SelectedFirstQuestionId, + SecurityQuestionAnswerHash = securityViewModel.SecurityFirstQuestionAnswerHash, + UserId = this.CurrentUserId, + }, + new UserSecurityQuestionViewModel + { + Id = securityViewModel.UserSecuritySecondQuestionId, + SecurityQuestionId = securityViewModel.SelectedSecondQuestionId, + SecurityQuestionAnswerHash = securityViewModel.SecuritySecondQuestionAnswerHash, + UserId = this.CurrentUserId, + }, + }; + + await this.userService.UpdateUserSecurityQuestions(userSecurityQuestions); + + this.ViewBag.SuccessMessage = CommonValidationErrorMessages.SecurityQuestionSuccessMessage; + this.ViewBag.MyAction = "MyAccountSecurity"; + return this.View("SuccessMessageMyAccount"); + } + else + { + return this.View("MyAccountSecurityQuestionsDetails", securityViewModel); + } + } + + return this.View("MyAccountSecurityQuestionsDetails", securityViewModel); + } + + /// + /// To update security questions. + /// + /// model. + /// The . + [HttpPost] + public async Task UpdateMyAccountSecurityQuestions(MyAcountSecurityQuestionsViewModel model) + { + bool duplicatesExist = false; + + if (model.SelectedFirstQuestionId == model.SelectedSecondQuestionId) + { + duplicatesExist = true; + } + + if (duplicatesExist) + { + this.ModelState.AddModelError("DuplicateQuestion", CommonValidationErrorMessages.DuplicateQuestion); + return this.View("MyAccountSecurityQuestionsDetails", model); + } + + if (this.ModelState.IsValid) + { + var userSecurityQuestions = new List + { + new UserSecurityQuestionViewModel + { + Id = model.UserSecurityFirstQuestionId, + SecurityQuestionId = model.SelectedFirstQuestionId, + SecurityQuestionAnswerHash = model.SecurityFirstQuestionAnswerHash, + UserId = this.CurrentUserId, + }, + new UserSecurityQuestionViewModel + { + Id = model.UserSecuritySecondQuestionId, + SecurityQuestionId = model.SelectedSecondQuestionId, + SecurityQuestionAnswerHash = model.SecuritySecondQuestionAnswerHash, + UserId = this.CurrentUserId, + }, + }; + + await this.userService.UpdateUserSecurityQuestions(userSecurityQuestions); + + this.ViewBag.SuccessMessage = CommonValidationErrorMessages.FirstQuestionSuccessMessage; + return this.View("SuccessMessage"); + } + else + { + return this.View("MyAccountSecurityQuestionsDetails", model); + } } /// @@ -827,8 +1103,7 @@ await this.userService.UpdateUserEmployment( LocationId = profile.LocationId, }); - this.ViewBag.SuccessMessage = "Your job details have been changed"; - return this.View("SuccessMessage"); + return this.RedirectToAction(nameof(this.ChangePrimarySpecialty), new UserPrimarySpecialtyUpdateViewModel { }); } else { @@ -862,6 +1137,9 @@ public async Task ChangePrimarySpecialty([FromQuery] UserPrimaryS viewModel.PageSize = UserDetailContentPageSize; viewModel.CurrentPage = viewModel.CurrentPage == 0 ? 1 : viewModel.CurrentPage; viewModel.OptionalSpecialtyItem = optionalSpecialty.FirstOrDefault(x => x.Name.ToLower() == "not applicable"); + viewModel.SelectedGradeId = profile.GradeId?.ToString() ?? null; + viewModel.SelectedJobRoleId = profile.JobRoleId; + viewModel.SelectedMedicalCouncilNo = profile.MedicalCouncilNo; if (searchSubmission && string.IsNullOrWhiteSpace(viewModel.FilterText)) { @@ -887,8 +1165,7 @@ await this.userService.UpdateUserEmployment( LocationId = profile.LocationId, }); - this.ViewBag.SuccessMessage = "Your primary specialty has been changed"; - return this.View("SuccessMessage"); + return this.RedirectToAction(nameof(this.ChangeStartDate), new UserStartDateUpdateViewModel { }); } else { @@ -940,8 +1217,7 @@ await this.userService.UpdateUserEmployment( LocationId = profile.LocationId, }); - this.ViewBag.SuccessMessage = "Your job start date has been changed"; - return this.View("SuccessMessage"); + return this.RedirectToAction(nameof(this.ChangeWorkPlace), new UserWorkPlaceUpdateViewModel { }); } } else @@ -977,45 +1253,6 @@ public async Task ChangeWorkPlace([FromQuery] UserWorkPlaceUpdate return this.View("ChangeWorkPlace", viewModel); } - if (formSubmission && viewModel.SelectedWorkPlaceId.HasValue) - { - await this.userService.UpdateUserEmployment( - new elfhHub.Nhs.Models.Entities.UserEmployment - { - Id = profile.EmploymentId, - UserId = profile.Id, - JobRoleId = profile.JobRoleId, - MedicalCouncilId = profile.MedicalCouncilId, - MedicalCouncilNo = profile.MedicalCouncilNo, - GradeId = profile.GradeId, - SpecialtyId = profile.SpecialtyId, - StartDate = profile.JobStartDate, - LocationId = viewModel.SelectedWorkPlaceId.Value, - }); - - var (cacheExists, loginWizard) = await this.cacheService.TryGetAsync(this.LoginWizardCacheKey); - - if (cacheExists && loginWizard.LoginWizardStagesRemaining.Any(l => l.Id == (int)LoginWizardStageEnum.PlaceOfWork)) - { - await this.loginWizardService.SaveLoginWizardStageActivity(LoginWizardStageEnum.PlaceOfWork, this.CurrentUserId); - - var stagePlaceOfWork = loginWizard.LoginWizardStages.FirstOrDefault(s => s.Id == (int)LoginWizardStageEnum.PlaceOfWork); - loginWizard.LoginWizardStagesCompleted.Add(stagePlaceOfWork); - - var loginWizardViewModel = new LoginWizardStagesViewModel - { - IsFirstLogin = loginWizard.IsFirstLogin, - LoginWizardStages = loginWizard.LoginWizardStages, - LoginWizardStagesCompleted = loginWizard.LoginWizardStagesCompleted, - }; - - await this.cacheService.SetAsync(this.LoginWizardCacheKey, Newtonsoft.Json.JsonConvert.SerializeObject(loginWizardViewModel)); - } - - this.ViewBag.SuccessMessage = "Your place of work has been changed"; - return this.View("SuccessMessage"); - } - if (!string.IsNullOrWhiteSpace(viewModel.FilterText)) { var locations = await this.locationService.GetPagedFilteredAsync(viewModel.FilterText, viewModel.CurrentPage, viewModel.PageSize); @@ -1024,6 +1261,54 @@ await this.userService.UpdateUserEmployment( viewModel.HasItems = locations.Item1 > 0; } + if (formSubmission) + { + if (viewModel.SelectedWorkPlaceId.HasValue) + { + await this.userService.UpdateUserEmployment( + new elfhHub.Nhs.Models.Entities.UserEmployment + { + Id = profile.EmploymentId, + UserId = profile.Id, + JobRoleId = profile.JobRoleId, + MedicalCouncilId = profile.MedicalCouncilId, + MedicalCouncilNo = profile.MedicalCouncilNo, + GradeId = profile.GradeId, + SpecialtyId = profile.SpecialtyId, + StartDate = profile.JobStartDate, + LocationId = viewModel.SelectedWorkPlaceId.Value, + }); + + var (cacheExists, loginWizard) = await this.cacheService.TryGetAsync(this.LoginWizardCacheKey); + + if (cacheExists && loginWizard.LoginWizardStagesRemaining.Any(l => l.Id == (int)LoginWizardStageEnum.PlaceOfWork)) + { + await this.loginWizardService.SaveLoginWizardStageActivity(LoginWizardStageEnum.PlaceOfWork, this.CurrentUserId); + + var stagePlaceOfWork = loginWizard.LoginWizardStages.FirstOrDefault(s => s.Id == (int)LoginWizardStageEnum.PlaceOfWork); + loginWizard.LoginWizardStagesCompleted.Add(stagePlaceOfWork); + + var loginWizardViewModel = new LoginWizardStagesViewModel + { + IsFirstLogin = loginWizard.IsFirstLogin, + LoginWizardStages = loginWizard.LoginWizardStages, + LoginWizardStagesCompleted = loginWizard.LoginWizardStagesCompleted, + }; + + await this.cacheService.SetAsync(this.LoginWizardCacheKey, Newtonsoft.Json.JsonConvert.SerializeObject(loginWizardViewModel)); + } + + this.ViewBag.SuccessMessage = CommonValidationErrorMessages.EmploymentDetailsUpdated; + this.ViewBag.MyAction = "MyEmploymentDetails"; + return this.View("SuccessMessageMyAccount"); + } + else + { + this.ModelState.AddModelError(nameof(viewModel.SelectedWorkPlaceId), CommonValidationErrorMessages.WorkPlace); + return this.View("ChangeWorkPlace", viewModel); + } + } + return this.View("ChangeWorkPlace", viewModel); } @@ -1197,5 +1482,49 @@ public async Task CancelEmailChangeValidationToken() this.ViewBag.SuccessMessage = CommonValidationErrorMessages.EmailCancelMessage; return this.View("SuccessMessage"); } + + private async Task MyAccountUpdatePrimaryEmail(string primaryEmailAddress) + { + bool userPrimaryEmailAddressChanged = false; + var user = await this.userService.GetUserByUserIdAsync(this.CurrentUserId); + if (user != null) + { + if (!string.IsNullOrEmpty(primaryEmailAddress) && user.EmailAddress.ToLower() != primaryEmailAddress.ToLower()) + { + userPrimaryEmailAddressChanged = true; + } + } + + if (userPrimaryEmailAddressChanged) + { + if (await this.userService.DoesEmailAlreadyExist(primaryEmailAddress)) + { + this.ModelState.AddModelError( + nameof(primaryEmailAddress), + CommonValidationErrorMessages.DuplicateEmailAddress); + } + else + { + var isUserRoleUpgrade = await this.userService.ValidateUserRoleUpgradeAsync(user.EmailAddress, primaryEmailAddress); + UserRoleUpgrade userRoleUpgradeModel = new UserRoleUpgrade() + { + UserId = this.CurrentUserId, + EmailAddress = primaryEmailAddress, + }; + if (isUserRoleUpgrade) + { + userRoleUpgradeModel.UserHistoryTypeId = (int)UserHistoryType.UserRoleUpgarde; + } + else + { + userRoleUpgradeModel.UserHistoryTypeId = (int)UserHistoryType.UserDetails; + } + + await this.userService.GenerateEmailChangeValidationTokenAndSendEmailAsync(primaryEmailAddress, isUserRoleUpgrade); + await this.userService.UpdateUserRoleUpgradeAsync(); + await this.userService.CreateUserRoleUpgradeAsync(userRoleUpgradeModel); + } + } + } } } \ No newline at end of file diff --git a/LearningHub.Nhs.WebUI/Helpers/CommonValidationErrorMessages.cs b/LearningHub.Nhs.WebUI/Helpers/CommonValidationErrorMessages.cs index c9b3aa7bc..440692fae 100644 --- a/LearningHub.Nhs.WebUI/Helpers/CommonValidationErrorMessages.cs +++ b/LearningHub.Nhs.WebUI/Helpers/CommonValidationErrorMessages.cs @@ -229,5 +229,30 @@ public static class CommonValidationErrorMessages /// Message if the validation token expired. /// public const string EmailChangeValidationTokenInvalidMessage = "We cannot find the page you are looking for"; + + /// + /// Message if the validation token expired. + /// + public const string InvalidSecurityQuestionAnswer = "Enter an answer"; + + /// + /// Message if the validation token expired. + /// + public const string EmploymentDetailsUpdated = "Your employment details has been changed"; + + /// + /// security question Success Message. + /// + public const string SecurityQuestionSuccessMessage = "Your security questions has been changed"; + + /// + /// location Success Message. + /// + public const string LocationDetailsSuccessMessage = "Your location details has been changed"; + + /// + /// location Success Message. + /// + public const string PersonalDetailsSuccessMessage = "Your personal details has been changed"; } } diff --git a/LearningHub.Nhs.WebUI/Helpers/SelectListHelper.cs b/LearningHub.Nhs.WebUI/Helpers/SelectListHelper.cs new file mode 100644 index 000000000..1dcd3f53e --- /dev/null +++ b/LearningHub.Nhs.WebUI/Helpers/SelectListHelper.cs @@ -0,0 +1,35 @@ +namespace LearningHub.Nhs.WebUI.Helpers +{ + using System.Collections.Generic; + using System.Linq; + using elfhHub.Nhs.Models.Common; + using Microsoft.AspNetCore.Mvc.Rendering; + + /// + /// SelectListHelper. + /// + public static class SelectListHelper + { + /// + /// MapOptionsToSelectListItems. + /// + /// options. + /// selectedId. + /// SelectListItem. + public static IEnumerable MapOptionsToSelectListItems(IEnumerable options, int? selectedId = null) + { + return options.Select(o => new SelectListItem(o.Name, o.Id.ToString(), o.Id == selectedId)).ToList(); + } + + /// + /// MapSelectListWithSelection. + /// + /// options. + /// selectedId. + /// SelectListItem. + public static IEnumerable MapSelectListWithSelection(IEnumerable options, string selectedId = null) + { + return options.Select(o => new SelectListItem(o.Text, o.Value, o.Value == selectedId)).ToList(); + } + } +} diff --git a/LearningHub.Nhs.WebUI/Interfaces/ICountryService.cs b/LearningHub.Nhs.WebUI/Interfaces/ICountryService.cs index 8b5fe7542..916159fe7 100644 --- a/LearningHub.Nhs.WebUI/Interfaces/ICountryService.cs +++ b/LearningHub.Nhs.WebUI/Interfaces/ICountryService.cs @@ -29,5 +29,17 @@ public interface ICountryService /// /// A representing the result of the asynchronous operation. Task> GetAllAsync(); + + /// + /// The GetAllUKCountries. + /// + /// A representing the result of the asynchronous operation. + Task> GetAllUKCountries(); + + /// + /// The GetAllNonUKCountries. + /// + /// A representing the result of the asynchronous operation. + Task> GetAllNonUKCountries(); } } diff --git a/LearningHub.Nhs.WebUI/Interfaces/IUserService.cs b/LearningHub.Nhs.WebUI/Interfaces/IUserService.cs index 19ee0a927..4fda81d60 100644 --- a/LearningHub.Nhs.WebUI/Interfaces/IUserService.cs +++ b/LearningHub.Nhs.WebUI/Interfaces/IUserService.cs @@ -478,5 +478,45 @@ public interface IUserService /// the string. /// base64 string. string Base64MD5HashDigest(string szString); + + /// + /// The get current user profile for My account. + /// + /// The . + Task GetMyAccountPersonalDetailsAsync(); + + /// + /// Update MyAccount Personal Details Async. + /// + /// userId. + /// MyAccountPersonalDetailsViewModel. + /// The . + Task UpdateMyAccountPersonalDetailsAsync(int userId, MyAccountPersonalDetailsViewModel model); + + /// + /// Get MyEmployment Details Async. + /// + /// The . + Task GetMyEmploymentDetailsAsync(); + + /// + /// Get MyAccount Security Details Async. + /// + /// The . + Task GetMyAccountSecurityDetailsAsync(); + + /// + /// Get MyAccount Location Details Async. + /// + /// The . + Task GetMyAccountLocationDetailsAsync(); + + /// + /// Update MyAccount Location Details Async. + /// + /// userId. + /// MyAccountLocationViewModel. + /// The . + Task UpdateMyAccountLocationDetailsAsync(int userId, MyAccountLocationViewModel model); } } diff --git a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj index a65aa93dd..43c0f9a35 100644 --- a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj +++ b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj @@ -107,7 +107,7 @@ - + diff --git a/LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationConfiguration.cs b/LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationConfiguration.cs index 6b7801793..bc000237c 100644 --- a/LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationConfiguration.cs +++ b/LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationConfiguration.cs @@ -26,30 +26,30 @@ public static IEnumerable GetGroupedMenus() new SideNavigationItem { Text = "Personal details", - Controller = "Account", - Action = "PersonalDetails", - IsActive = route => MatchRoute(route, "Account", "PersonalDetails"), + Controller = "MyAccount", + Action = "Index", + IsActive = route => MatchRoute(route, "MyAccount", "Index"), }, new SideNavigationItem { Text = "My employment", - Controller = "Account", - Action = "MyEmployment", - IsActive = route => MatchRoute(route, "Account", "MyEmployment"), + Controller = "MyAccount", + Action = "MyEmploymentDetails", + IsActive = route => MatchRoute(route, "MyAccount", "MyEmploymentDetails"), }, new SideNavigationItem { Text = "Security", - Controller = "Account", - Action = "Security", - IsActive = route => MatchRoute(route, "Account", "Security"), + Controller = "MyAccount", + Action = "MyAccountSecurity", + IsActive = route => MatchRoute(route, "MyAccount", "MyAccountSecurity"), }, new SideNavigationItem { Text = "Notification", - Controller = "Account", - Action = "Notification", - IsActive = route => MatchRoute(route, "Account", "Notification"), + Controller = "Notification", + Action = "Index", + IsActive = route => MatchRoute(route, "Notification", "Index"), }, }, }, diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountEmploymentDetailsViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountEmploymentDetailsViewModel.cs new file mode 100644 index 000000000..41b93b692 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountEmploymentDetailsViewModel.cs @@ -0,0 +1,95 @@ +namespace LearningHub.Nhs.WebUI.Models.UserProfile +{ + using System; + + /// + /// Defines the . + /// + public class MyAccountEmploymentDetailsViewModel + { + /// + /// Gets or sets the Id. + /// + public int Id { get; set; } + + /// + /// Gets or sets the Country. + /// + public string Country { get; set; } + + /// + /// Gets or sets the Region. + /// + public string Region { get; set; } + + /// + /// Gets or sets the CountryName. + /// + public string CountryName { get; set; } + + /// + /// Gets or sets the RegionName. + /// + public string RegionName { get; set; } + + /// + /// Gets or sets the user employment id. + /// + public int EmploymentId { get; set; } + + /// + /// Gets or sets the job role id. + /// + public int? JobRoleId { get; set; } + + /// + /// Gets or sets the CurrentRole. + /// + public string JobRole { get; set; } + + /// + /// Gets or sets the medical council id. + /// + public int? MedicalCouncilId { get; set; } + + /// + /// Gets or sets the ProfessionalRegistrationNumber. + /// + public string MedicalCouncilNo { get; set; } + + /// + /// Gets or sets the grade id. + /// + public int? GradeId { get; set; } + + /// + /// Gets or sets the Grade. + /// + public string Grade { get; set; } + + /// + /// Gets or sets the specialty id. + /// + public int? SpecialtyId { get; set; } + + /// + /// Gets or sets the PrimarySpecialty. + /// + public string PrimarySpecialty { get; set; } + + /// + /// Gets or sets the StartDate. + /// + public DateTimeOffset? JobStartDate { get; set; } + + /// + /// Gets or sets the location id. + /// + public int LocationId { get; set; } + + /// + /// Gets or sets the PlaceOfWork. + /// + public string PlaceOfWork { get; set; } + } +} diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountLocationViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountLocationViewModel.cs new file mode 100644 index 000000000..58bd757ae --- /dev/null +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountLocationViewModel.cs @@ -0,0 +1,65 @@ +namespace LearningHub.Nhs.WebUI.Models.UserProfile +{ + using System.Collections.Generic; + using System.ComponentModel; + using Microsoft.AspNetCore.Mvc.Rendering; + using NHSUKViewComponents.Web.ViewModels; + + /// + /// Defines the . + /// + public class MyAccountLocationViewModel + { + /// + /// Gets or sets the country id. + /// + [DisplayName("Country")] + public int? SelectedCountryId { get; set; } + + /// + /// Gets or sets the region id. + /// + [DisplayName("Region")] + public int? SelectedRegionId { get; set; } + + /// + /// Gets or sets selected country name. + /// + public string SelectedCountryName { get; set; } + + /// + /// Gets or sets selected region name. + /// + public string SelectedRegionName { get; set; } + + /// + /// Gets or sets the country id. + /// + public int? SelectedOtherCountryId { get; set; } + + /// + /// Gets or sets a value indicating whether SelectedOtherCountry. + /// + public bool HasSelectedOtherCountry { get; set; } + + /// + /// Gets or sets a value indicating whether SelectedRegion. + /// + public bool HasSelectedRegion { get; set; } + + /// + /// Gets or sets the Country. + /// + public List Country { get; set; } + + /// + /// Gets or sets the OtherCountryOptions. + /// + public IEnumerable OtherCountryOptions { get; set; } + + /// + /// Gets or sets the RegionOptions. + /// + public IEnumerable RegionOptions { get; set; } + } +} diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountPersonalDetailsViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountPersonalDetailsViewModel.cs new file mode 100644 index 000000000..194bcc89a --- /dev/null +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountPersonalDetailsViewModel.cs @@ -0,0 +1,75 @@ +namespace LearningHub.Nhs.WebUI.Models.UserProfile +{ + using System.ComponentModel; + using System.ComponentModel.DataAnnotations; + using LearningHub.Nhs.WebUI.Attributes; + using LearningHub.Nhs.WebUI.Helpers; + using LearningHub.Nhs.WebUI.Validation; + + /// + /// Defines the . + /// + public class MyAccountPersonalDetailsViewModel + { + /// + /// Gets or sets the UserName. + /// + [DisplayName("Username")] + public string UserName { get; set; } + + /// + /// Gets or sets the Name. + /// + [DisplayName("Name")] + public string Name { get; set; } + + /// + /// Gets or sets the FirstName. + /// + [Required(ErrorMessage = "Enter a first name")] + [StringLength(50, MinimumLength = 1, ErrorMessage = "First name must be less than 50 characters.")] + [DisplayName("First name")] + public string FirstName { get; set; } + + /// + /// Gets or sets the LastName. + /// + [Required(ErrorMessage = "Enter a last name")] + [StringLength(50, MinimumLength = 1, ErrorMessage = "Last name must be less than 50 characters.")] + [DisplayName("Last name")] + public string LastName { get; set; } + + /// + /// Gets or sets the PreferredName. + /// + [StringLength(50, MinimumLength = 0, ErrorMessage = "Preferred name must be less than 50 characters.")] + [DisplayName("Preferred name")] + public string PreferredName { get; set; } + + /// + /// Gets or sets the Primary Email Address. + /// + [DataType(DataType.EmailAddress)] + [Required(ErrorMessage = "Enter a primary email address")] + [MaxLength(100, ErrorMessage = CommonValidationErrorMessages.TooLongEmail)] + [EmailAddress(ErrorMessage = CommonValidationErrorMessages.InvalidEmail)] + [NoWhitespace(ErrorMessage = CommonValidationErrorMessages.WhitespaceInEmail)] + [DisplayName("Primary email address")] + public string PrimaryEmailAddress { get; set; } + + /// + /// Gets or sets the new primary email address. + /// + public string NewPrimaryEmailAddress { get; set; } + + /// + /// Gets or sets the SecondaryEmailAddress. + /// + [DataType(DataType.EmailAddress)] + [NotEqual("PrimaryEmailAddress", ErrorMessage = CommonValidationErrorMessages.SecondaryEmailShouldNotBeSame)] + [MaxLength(100, ErrorMessage = CommonValidationErrorMessages.TooLongEmail)] + [EmailAddress(ErrorMessage = CommonValidationErrorMessages.InvalidEmail)] + [NoWhitespace(ErrorMessage = CommonValidationErrorMessages.WhitespaceInEmail)] + public string SecondaryEmailAddress { get; set; } + } +} diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountSecurityViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountSecurityViewModel.cs new file mode 100644 index 000000000..d1a26f4c1 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAccountSecurityViewModel.cs @@ -0,0 +1,45 @@ +namespace LearningHub.Nhs.WebUI.Models.UserProfile +{ + using System; + + /// + /// Defines the . + /// + public class MyAccountSecurityViewModel + { + /// + /// Gets or sets the Id. + /// + public int Id { get; set; } + + /// + /// Gets or sets the SecondaryEmailAddress. + /// + public string SecondaryEmailAddress { get; set; } + + /// + /// Gets or sets the SecurityFirstQuestion. + /// + public string SecurityFirstQuestion { get; set; } + + /// + /// Gets or sets the SecuritySecondQuestion. + /// + public string SecuritySecondQuestion { get; set; } + + /////// + /////// Gets or sets the LastUpdated. + /////// + ////public DateTimeOffset LastUpdated { get; set; } + + /// + /// Gets or sets the PasswordHash. + /// + public string PasswordHash { get; set; } + + /// + /// Gets or sets the SecurityQuestionLastUpdated. + /// + public string SecurityQuestionLastUpdated { get; set; } + } +} diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/MyAcountSecurityQuestionsViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAcountSecurityQuestionsViewModel.cs new file mode 100644 index 000000000..7712ae470 --- /dev/null +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/MyAcountSecurityQuestionsViewModel.cs @@ -0,0 +1,54 @@ +namespace LearningHub.Nhs.WebUI.Models.UserProfile +{ + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using elfhHub.Nhs.Models.Common; + using Microsoft.AspNetCore.Mvc.Rendering; + using NHSUKViewComponents.Web.ViewModels; + + /// + /// Defines the . + /// + public class MyAcountSecurityQuestionsViewModel + { + /// + /// Gets or sets selectedQuestion. + /// + public int SelectedFirstQuestionId { get; set; } + + /// + /// Gets or sets selectedQuestion. + /// + public int SelectedSecondQuestionId { get; set; } + + /// + /// Gets or sets the security question answer hash. + /// + public string SecurityFirstQuestionAnswerHash { get; set; } + + /// + /// Gets or sets the security question answer hash. + /// + public string SecuritySecondQuestionAnswerHash { get; set; } + + /// + /// Gets or sets the FirstSecurityQuestions. + /// + public IEnumerable FirstSecurityQuestions { get; set; } + + /// + /// Gets or sets the SecondSecurityQuestions. + /// + public IEnumerable SecondSecurityQuestions { get; set; } + + /// + /// Gets or sets the UserSecurityFirstQuestionId. + /// + public int UserSecurityFirstQuestionId { get; set; } + + /// + /// Gets or sets the UserSecurityFirstQuestionId. + /// + public int UserSecuritySecondQuestionId { get; set; } + } +} diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/UserPrimarySpecialtyUpdateViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/UserPrimarySpecialtyUpdateViewModel.cs index 8dd1546ed..5c91bd661 100644 --- a/LearningHub.Nhs.WebUI/Models/UserProfile/UserPrimarySpecialtyUpdateViewModel.cs +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/UserPrimarySpecialtyUpdateViewModel.cs @@ -36,6 +36,21 @@ public class UserPrimarySpecialtyUpdateViewModel : PagingViewModel /// public GenericListViewModel OptionalSpecialtyItem { get; set; } + /// + /// Gets or sets the selected job role id. + /// + public int? SelectedJobRoleId { get; set; } + + /// + /// Gets or sets the selected grade id. + /// + public string SelectedGradeId { get; set; } + + /// + /// Gets or sets the selected medical council number. + /// + public string SelectedMedicalCouncilNo { get; set; } + /// /// sets the list of radio specialty. /// diff --git a/LearningHub.Nhs.WebUI/Models/UserProfile/UserStartDateUpdateViewModel.cs b/LearningHub.Nhs.WebUI/Models/UserProfile/UserStartDateUpdateViewModel.cs index 8d45071cd..372427781 100644 --- a/LearningHub.Nhs.WebUI/Models/UserProfile/UserStartDateUpdateViewModel.cs +++ b/LearningHub.Nhs.WebUI/Models/UserProfile/UserStartDateUpdateViewModel.cs @@ -30,6 +30,16 @@ public class UserStartDateUpdateViewModel : IValidatableObject /// public int? Year { get; set; } + /////// + /////// Gets or sets filter text. + /////// + ////public string FilterText { get; set; } + + /// + /// Gets or sets the selected primary specialty id. + /// + public int? SelectedPrimarySpecialtyId { get; set; } + /// /// Gets or sets the GetDate. /// diff --git a/LearningHub.Nhs.WebUI/Scripts/vuesrc/notification/notification.vue b/LearningHub.Nhs.WebUI/Scripts/vuesrc/notification/notification.vue index 25ef12656..84fb2eb0c 100644 --- a/LearningHub.Nhs.WebUI/Scripts/vuesrc/notification/notification.vue +++ b/LearningHub.Nhs.WebUI/Scripts/vuesrc/notification/notification.vue @@ -1,7 +1,7 @@