Skip to content

Commit 9582e95

Browse files
authored
Merge pull request #1457 from TechnologyEnhancedLearning/Develop/Fixes/TD-6133-Issues-on-'My-Account-My-employmentdetails'-screen
TD-6133: Fixed issues on 'My Account - My employment details' screen
2 parents 9722f6a + e47123e commit 9582e95

File tree

26 files changed

+48
-34
lines changed

26 files changed

+48
-34
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.11" />
86+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.12" />
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
14+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.12" />
1515
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1616
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
1717
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />

LearningHub.Nhs.WebUI/Controllers/AccountController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ public async Task<IActionResult> CreateAccountWorkPlace(AccountCreationViewModel
999999
if (!string.IsNullOrWhiteSpace(accountCreation.LocationId))
10001000
{
10011001
var selectedLocation = await this.locationService.GetByIdAsync(int.Parse(accountCreation.LocationId));
1002-
return this.View(new AccountCreationListViewModel { WorkPlaceList = new List<LocationBasicViewModel> { selectedLocation }, FilterText = selectedLocation.Name, AccountCreationPaging = new AccountCreationPagingModel { TotalItems = 1, PageSize = UserRegistrationContentPageSize, HasItems = selectedLocation != null, CurrentPage = 1 }, LocationId = accountCreation.LocationId, ReturnToConfirmation = accountCreationViewModel.ReturnToConfirmation });
1002+
return this.View(new AccountCreationListViewModel { WorkPlaceList = new List<LocationBasicViewModel> { selectedLocation }, FilterText = selectedLocation.NameWithoutSubName, AccountCreationPaging = new AccountCreationPagingModel { TotalItems = 1, PageSize = UserRegistrationContentPageSize, HasItems = selectedLocation != null, CurrentPage = 1 }, LocationId = accountCreation.LocationId, ReturnToConfirmation = accountCreationViewModel.ReturnToConfirmation });
10031003
}
10041004

10051005
accountCreationViewModel.PrimarySpecialtyId = accountCreation.PrimarySpecialtyId;

LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,17 +1349,10 @@ public async Task<IActionResult> ChangeWorkPlace([FromQuery] UserWorkPlaceUpdate
13491349
return this.View("ChangeWorkPlace", viewModel);
13501350
}
13511351

1352-
if (!string.IsNullOrWhiteSpace(viewModel.FilterText))
1353-
{
1354-
var locations = await this.locationService.GetPagedFilteredAsync(viewModel.FilterText, viewModel.CurrentPage, viewModel.PageSize);
1355-
viewModel.WorkPlaceList = locations.Item2;
1356-
viewModel.TotalItems = locations.Item1;
1357-
viewModel.HasItems = locations.Item1 > 0;
1358-
}
1359-
13601352
if (formSubmission)
13611353
{
1362-
if (viewModel.SelectedWorkPlaceId.HasValue)
1354+
var hasSelectedWorkPlace = int.TryParse(viewModel.SelectedWorkPlaceId, out int selectedWorkPlaceId);
1355+
if (hasSelectedWorkPlace && selectedWorkPlaceId > 0)
13631356
{
13641357
await this.userService.UpdateUserEmployment(
13651358
new elfhHub.Nhs.Models.Entities.UserEmployment
@@ -1372,7 +1365,7 @@ await this.userService.UpdateUserEmployment(
13721365
GradeId = profile.GradeId,
13731366
SpecialtyId = profile.SpecialtyId,
13741367
StartDate = profile.JobStartDate,
1375-
LocationId = viewModel.SelectedWorkPlaceId.Value,
1368+
LocationId = selectedWorkPlaceId,
13761369
});
13771370

13781371
var (cacheExists, loginWizard) = await this.cacheService.TryGetAsync<Models.Account.LoginWizardViewModel>(this.LoginWizardCacheKey);
@@ -1401,9 +1394,24 @@ await this.userService.UpdateUserEmployment(
14011394
else
14021395
{
14031396
this.ModelState.AddModelError(nameof(viewModel.SelectedWorkPlaceId), CommonValidationErrorMessages.WorkPlace);
1404-
return this.View("ChangeWorkPlace", viewModel);
14051397
}
14061398
}
1399+
else
1400+
{
1401+
if (!searchSubmission)
1402+
{
1403+
viewModel.SelectedWorkPlaceId = profile.LocationId.ToString();
1404+
viewModel.FilterText = profile.LocationName;
1405+
}
1406+
}
1407+
1408+
if (!string.IsNullOrWhiteSpace(viewModel.FilterText))
1409+
{
1410+
var locations = await this.locationService.GetPagedFilteredAsync(viewModel.FilterText, viewModel.CurrentPage, viewModel.PageSize);
1411+
viewModel.WorkPlaceList = locations.Item2;
1412+
viewModel.TotalItems = locations.Item1;
1413+
viewModel.HasItems = locations.Item1 > 0;
1414+
}
14071415

14081416
return this.View("ChangeWorkPlace", viewModel);
14091417
}

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.11" />
110+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.12" />
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/UserProfile/UserProfileSummaryViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,10 @@ public class UserProfileSummaryViewModel
146146
/// Gets or sets the new primary email address.
147147
/// </summary>
148148
public string NewPrimaryEmailAddress { get; set; }
149+
150+
/// <summary>
151+
/// Gets or sets the location name without sub name.
152+
/// </summary>
153+
public string LocationName { get; set; }
149154
}
150155
}

LearningHub.Nhs.WebUI/Models/UserProfile/UserWorkPlaceUpdateViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class UserWorkPlaceUpdateViewModel : PagingViewModel
2525
/// <summary>
2626
/// Gets or sets the selected work place id.
2727
/// </summary>
28-
public int? SelectedWorkPlaceId { get; set; }
28+
public string SelectedWorkPlaceId { get; set; }
2929

3030
/// <summary>
3131
/// Gets or sets the WorkPlaceList.

LearningHub.Nhs.WebUI/Services/UserService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@ public async Task<UserProfileSummaryViewModel> GetUserProfileSummaryAsync()
12311231

12321232
var location = await this.locationService.GetByIdAsync(employmentViewModel.LocationId);
12331233
viewModel.PlaceOfWork = $"{location.Name}<br />Address: {location.Address}<br />Org Code: {location.NhsCode}";
1234+
viewModel.LocationName = location.NameWithoutSubName;
12341235
}
12351236

12361237
return viewModel;

OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
19+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.12" />
2020
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
2121
</ItemGroup>
2222

OpenAPI/LearningHub.Nhs.OpenApi.Services/LearningHub.Nhs.OpenApi.Services.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<PackageReference Include="Azure.Storage.Blobs" Version="12.14.1" />
3030
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0" />
3131
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
32-
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.11" />
32+
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.12" />
3333
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.57" />
3434
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.1" />
3535
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />

0 commit comments

Comments
 (0)