Skip to content

Commit fcff003

Browse files
committed
TD-5761: Draft commit
1 parent f2aa99a commit fcff003

File tree

36 files changed

+1269
-345
lines changed

36 files changed

+1269
-345
lines changed

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
8484
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0" />
8585
<PackageReference Include="BuildWebCompiler" Version="1.12.405" />
86-
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
86+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
8787
<PackageReference Include="FluentValidation" Version="11.11.0" />
8888
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
8989
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />

LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
1415
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1516
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />

LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs

Lines changed: 145 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,91 @@ public async Task<IActionResult> Index(string returnUrl = null, bool? checkDetai
131131
}
132132
}
133133

134+
var userPersonalDetails = await this.userService.GetMyAccountPersonalDetailsAsync();
135+
////var userProfileSummary = await this.userService.GetUserProfileSummaryAsync();
136+
////var userProfileSummary1 = await this.userService.GetCurrentUserBasicDetailsAsync();
137+
return this.View("Index", userPersonalDetails);
138+
}
139+
140+
/// <summary>
141+
/// MyEmploymentDetails.
142+
/// </summary>
143+
/// <returns>IActionResult.</returns>
144+
[HttpGet]
145+
[Route("myaccount-employement")]
146+
public async Task<IActionResult> MyEmploymentDetails()
147+
{
148+
var employmentDetails = await this.userService.GetMyEmploymentDetailsAsync();
149+
return this.View("MyEmployment", employmentDetails);
150+
}
151+
152+
/// <summary>
153+
/// User profile actions.
154+
/// </summary>
155+
/// <param name="returnUrl">The redirect back url.</param>
156+
/// <param name="checkDetails">Whether to check account details.</param>
157+
/// <returns>IActionResult.</returns>
158+
[HttpGet]
159+
[Route("myaccount-security")]
160+
public async Task<IActionResult> MyAccountSecurity(string returnUrl = null, bool? checkDetails = false)
161+
{
162+
var securityDetails = await this.userService.GetMyAccountSecurityDetailsAsync();
163+
return this.View("MyAccountSecurity", securityDetails);
164+
}
165+
166+
/// <summary>
167+
/// ChangePersonalDetails.
168+
/// </summary>
169+
/// <returns>ActionResult.</returns>
170+
[HttpGet]
171+
[Route("myaccount/ChangePersonalDetails")]
172+
public async Task<IActionResult> ChangePersonalDetails()
173+
{
174+
var userPersonalDetails = await this.userService.GetMyAccountPersonalDetailsAsync();
175+
return this.View("ChangePersonalDetails", userPersonalDetails);
176+
}
177+
178+
/// <summary>
179+
/// To Update first name.
180+
/// </summary>
181+
/// <param name="model">model.</param>
182+
/// <returns>ActionResult.</returns>
183+
[HttpPost]
184+
public async Task<IActionResult> UpdatePersonalDetails(MyAccountPersonalDetailsViewModel model)
185+
{
186+
if (!this.ModelState.IsValid)
187+
{
188+
return this.View("ChangePersonalDetails", model);
189+
}
190+
191+
await this.userService.UpdateMyAccountPersonalDetailsAsync(this.CurrentUserId, model);
192+
await this.MyAccountUpdatePrimaryEmail(model.PrimaryEmailAddress);
193+
this.ViewBag.SuccessMessage = "Success";
194+
return this.View("SuccessMessage");
195+
}
196+
197+
/// <summary>
198+
/// ChangeLocation.
199+
/// </summary>
200+
/// <param name="selectedCountryId">country id.</param>
201+
/// <returns>ActionResult.</returns>
202+
[HttpGet]
203+
[Route("myaccount/ChangeLocation")]
204+
public async Task<IActionResult> ChangeLocation(int? selectedCountryId)
205+
{
206+
this.TempData.Clear();
207+
var userLocationViewModel = await this.userService.GetUserLocationDetailsAsync();
134208
var userProfileSummary = await this.userService.GetUserProfileSummaryAsync();
135-
return this.View("Index", userProfileSummary);
209+
if (selectedCountryId.HasValue)
210+
{
211+
userLocationViewModel.SelectedCountryId = selectedCountryId;
212+
}
213+
214+
await this.multiPageFormService.SetMultiPageFormData(
215+
userLocationViewModel,
216+
MultiPageFormDataFeature.AddRegistrationPrompt,
217+
this.TempData);
218+
return this.View("ChangeLocation", new Tuple<UserProfileSummaryViewModel, UserLocationViewModel>(userProfileSummary, userLocationViewModel));
136219
}
137220

138221
/// <summary>
@@ -827,8 +910,10 @@ await this.userService.UpdateUserEmployment(
827910
LocationId = profile.LocationId,
828911
});
829912

830-
this.ViewBag.SuccessMessage = "Your job details have been changed";
831-
return this.View("SuccessMessage");
913+
////this.ViewBag.SuccessMessage = "Your job details have been changed";
914+
////return this.View("SuccessMessage");
915+
916+
return this.RedirectToAction(nameof(this.ChangePrimarySpecialty), new UserPrimarySpecialtyUpdateViewModel { });
832917
}
833918
else
834919
{
@@ -887,8 +972,10 @@ await this.userService.UpdateUserEmployment(
887972
LocationId = profile.LocationId,
888973
});
889974

890-
this.ViewBag.SuccessMessage = "Your primary specialty has been changed";
891-
return this.View("SuccessMessage");
975+
////this.ViewBag.SuccessMessage = "Your primary specialty has been changed";
976+
////return this.View("SuccessMessage");
977+
978+
return this.RedirectToAction(nameof(this.ChangeStartDate), new UserStartDateUpdateViewModel { });
892979
}
893980
else
894981
{
@@ -940,8 +1027,10 @@ await this.userService.UpdateUserEmployment(
9401027
LocationId = profile.LocationId,
9411028
});
9421029

943-
this.ViewBag.SuccessMessage = "Your job start date has been changed";
944-
return this.View("SuccessMessage");
1030+
////this.ViewBag.SuccessMessage = "Your job start date has been changed";
1031+
////return this.View("SuccessMessage");
1032+
1033+
return this.RedirectToAction(nameof(this.ChangeWorkPlace), new UserWorkPlaceUpdateViewModel { });
9451034
}
9461035
}
9471036
else
@@ -1012,7 +1101,7 @@ await this.userService.UpdateUserEmployment(
10121101
await this.cacheService.SetAsync(this.LoginWizardCacheKey, Newtonsoft.Json.JsonConvert.SerializeObject(loginWizardViewModel));
10131102
}
10141103

1015-
this.ViewBag.SuccessMessage = "Your place of work has been changed";
1104+
this.ViewBag.SuccessMessage = "Your employment details have been updated";
10161105
return this.View("SuccessMessage");
10171106
}
10181107

@@ -1197,5 +1286,53 @@ public async Task<ActionResult> CancelEmailChangeValidationToken()
11971286
this.ViewBag.SuccessMessage = CommonValidationErrorMessages.EmailCancelMessage;
11981287
return this.View("SuccessMessage");
11991288
}
1289+
1290+
private async Task MyAccountUpdatePrimaryEmail(string primaryEmailAddress)
1291+
{
1292+
bool userPrimaryEmailAddressChanged = false;
1293+
var user = await this.userService.GetUserByUserIdAsync(this.CurrentUserId);
1294+
if (user != null)
1295+
{
1296+
if (!string.IsNullOrEmpty(primaryEmailAddress) && user.EmailAddress.ToLower() != primaryEmailAddress.ToLower())
1297+
{
1298+
userPrimaryEmailAddressChanged = true;
1299+
}
1300+
}
1301+
1302+
if (userPrimaryEmailAddressChanged)
1303+
{
1304+
if (await this.userService.DoesEmailAlreadyExist(primaryEmailAddress))
1305+
{
1306+
this.ModelState.AddModelError(
1307+
nameof(primaryEmailAddress),
1308+
CommonValidationErrorMessages.DuplicateEmailAddress);
1309+
////return this.View("ChangePrimaryEmail", primaryEmailAddress);
1310+
}
1311+
else
1312+
{
1313+
var isUserRoleUpgrade = await this.userService.ValidateUserRoleUpgradeAsync(user.EmailAddress, primaryEmailAddress);
1314+
UserRoleUpgrade userRoleUpgradeModel = new UserRoleUpgrade()
1315+
{
1316+
UserId = this.CurrentUserId,
1317+
EmailAddress = primaryEmailAddress,
1318+
};
1319+
if (isUserRoleUpgrade)
1320+
{
1321+
userRoleUpgradeModel.UserHistoryTypeId = (int)UserHistoryType.UserRoleUpgarde;
1322+
}
1323+
else
1324+
{
1325+
userRoleUpgradeModel.UserHistoryTypeId = (int)UserHistoryType.UserDetails;
1326+
}
1327+
1328+
await this.userService.GenerateEmailChangeValidationTokenAndSendEmailAsync(primaryEmailAddress, isUserRoleUpgrade);
1329+
await this.userService.UpdateUserRoleUpgradeAsync();
1330+
await this.userService.CreateUserRoleUpgradeAsync(userRoleUpgradeModel);
1331+
////this.ViewBag.SuccessMessage = CommonValidationErrorMessages.EmailChangeRequestedSucessMessage;
1332+
////this.ViewBag.Status = "Valid";
1333+
////return this.View("ConfirmEmailSuccessMessage");
1334+
}
1335+
}
1336+
}
12001337
}
12011338
}

LearningHub.Nhs.WebUI/Interfaces/IUserService.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,5 +478,31 @@ public interface IUserService
478478
/// <param name="szString">the string.</param>
479479
/// <returns>base64 string.</returns>
480480
string Base64MD5HashDigest(string szString);
481+
482+
/// <summary>
483+
/// The get current user profile for My account.
484+
/// </summary>
485+
/// <returns>The <see cref="Task{MyAccountPersonalDetailsViewModel}"/>.</returns>
486+
Task<MyAccountPersonalDetailsViewModel> GetMyAccountPersonalDetailsAsync();
487+
488+
/// <summary>
489+
/// Update MyAccount Personal Details Async.
490+
/// </summary>
491+
/// <param name="userId">userId.</param>
492+
/// <param name="model">MyAccountPersonalDetailsViewModel.</param>
493+
/// <returns>The <see cref="Task"/>.</returns>
494+
Task UpdateMyAccountPersonalDetailsAsync(int userId, MyAccountPersonalDetailsViewModel model);
495+
496+
/// <summary>
497+
/// Get MyEmployment Details Async.
498+
/// </summary>
499+
/// <returns>The <see cref="Task{MyAccountEmploymentDetailsViewModel}"/>.</returns>
500+
Task<MyAccountEmploymentDetailsViewModel> GetMyEmploymentDetailsAsync();
501+
502+
/// <summary>
503+
/// Get MyAccount Security Details Async.
504+
/// </summary>
505+
/// <returns>The <see cref="Task{MyAccountSecurityViewModel}"/>.</returns>
506+
Task<MyAccountSecurityViewModel> GetMyAccountSecurityDetailsAsync();
481507
}
482508
}

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
108108
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
109109
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
110-
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
110+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
111111
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
112112
<PackageReference Include="GDS.MultiPageFormData" Version="1.0.6" />
113113
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />

LearningHub.Nhs.WebUI/Models/SideMenu/SideNavigationConfiguration.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ public static IEnumerable<SideNavigationGroup> GetGroupedMenus()
2626
new SideNavigationItem
2727
{
2828
Text = "Personal details",
29-
Controller = "Account",
30-
Action = "PersonalDetails",
31-
IsActive = route => MatchRoute(route, "Account", "PersonalDetails"),
29+
Controller = "MyAccount",
30+
Action = "Index",
31+
IsActive = route => MatchRoute(route, "MyAccount", "PersonalDetails"),
3232
},
3333
new SideNavigationItem
3434
{
3535
Text = "My employment",
36-
Controller = "Account",
37-
Action = "MyEmployment",
38-
IsActive = route => MatchRoute(route, "Account", "MyEmployment"),
36+
Controller = "MyAccount",
37+
Action = "MyEmploymentDetails",
38+
IsActive = route => MatchRoute(route, "MyAccount", "MyEmploymentDetails"),
3939
},
4040
new SideNavigationItem
4141
{
4242
Text = "Security",
43-
Controller = "Account",
44-
Action = "Security",
45-
IsActive = route => MatchRoute(route, "Account", "Security"),
43+
Controller = "MyAccount",
44+
Action = "MyAccountSecurity",
45+
IsActive = route => MatchRoute(route, "MyAccount", "MyAccountSecurity"),
4646
},
4747
new SideNavigationItem
4848
{
4949
Text = "Notification",
50-
Controller = "Account",
51-
Action = "Notification",
52-
IsActive = route => MatchRoute(route, "Account", "Notification"),
50+
Controller = "Notification",
51+
Action = "Index",
52+
IsActive = route => MatchRoute(route, "Notification", "Index"),
5353
},
5454
},
5555
},
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
namespace LearningHub.Nhs.WebUI.Models.UserProfile
2+
{
3+
using System;
4+
5+
/// <summary>
6+
/// Defines the <see cref="MyAccountEmploymentDetailsViewModel" />.
7+
/// </summary>
8+
public class MyAccountEmploymentDetailsViewModel
9+
{
10+
/// <summary>
11+
/// Gets or sets the Id.
12+
/// </summary>
13+
public int Id { get; set; }
14+
15+
/// <summary>
16+
/// Gets or sets the Country.
17+
/// </summary>
18+
public string Country { get; set; }
19+
20+
/// <summary>
21+
/// Gets or sets the Region.
22+
/// </summary>
23+
public string Region { get; set; }
24+
25+
/// <summary>
26+
/// Gets or sets the CountryName.
27+
/// </summary>
28+
public string CountryName { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the RegionName.
32+
/// </summary>
33+
public string RegionName { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the user employment id.
37+
/// </summary>
38+
public int EmploymentId { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the job role id.
42+
/// </summary>
43+
public int? JobRoleId { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the CurrentRole.
47+
/// </summary>
48+
public string JobRole { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets the medical council id.
52+
/// </summary>
53+
public int? MedicalCouncilId { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the ProfessionalRegistrationNumber.
57+
/// </summary>
58+
public string MedicalCouncilNo { get; set; }
59+
60+
/// <summary>
61+
/// Gets or sets the grade id.
62+
/// </summary>
63+
public int? GradeId { get; set; }
64+
65+
/// <summary>
66+
/// Gets or sets the Grade.
67+
/// </summary>
68+
public string Grade { get; set; }
69+
70+
/// <summary>
71+
/// Gets or sets the specialty id.
72+
/// </summary>
73+
public int? SpecialtyId { get; set; }
74+
75+
/// <summary>
76+
/// Gets or sets the PrimarySpecialty.
77+
/// </summary>
78+
public string PrimarySpecialty { get; set; }
79+
80+
/// <summary>
81+
/// Gets or sets the StartDate.
82+
/// </summary>
83+
public DateTimeOffset? JobStartDate { get; set; }
84+
85+
/// <summary>
86+
/// Gets or sets the location id.
87+
/// </summary>
88+
public int LocationId { get; set; }
89+
90+
/// <summary>
91+
/// Gets or sets the PlaceOfWork.
92+
/// </summary>
93+
public string PlaceOfWork { get; set; }
94+
}
95+
}

0 commit comments

Comments
 (0)