Skip to content

Commit 8044b46

Browse files
TD-5736: Replace existing Web UI service SMTP notifications with Gov Notify messaging service equivalents
1 parent c230650 commit 8044b46

File tree

30 files changed

+586
-149
lines changed

30 files changed

+586
-149
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="FluentAssertions" Version="6.12.0" />
15+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.49" />
1516
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1718
<PackageReference Include="Selenium.Axe" Version="4.0.19" />

LearningHub.Nhs.WebUI/Controllers/Api/CatalogueController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public async Task<IActionResult> GetLatestCatalogueAccessRequestAsync(int catalo
129129
[HttpPost("catalogue/RequestAccess/{reference}")]
130130
public async Task<IActionResult> RequestAccess(string reference, CatalogueAccessRequestViewModel vm)
131131
{
132-
return this.Ok(await this.catalogueService.RequestAccessAsync(reference, vm, "access"));
132+
return this.Ok(await this.catalogueService.RequestAccessAsync(reference, null, vm, "access"));
133133
}
134134

135135
/// <summary>

LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ public async Task<IActionResult> RequestAccess(CatalogueRequestAccessViewModel v
439439
{
440440
if (this.ModelState.IsValid)
441441
{
442-
var validationResult = await this.catalogueService.RequestAccessAsync(viewModel.CatalogueUrl, new CatalogueAccessRequestViewModel() { Message = viewModel.AccessRequestMessage, RoleId = (int)RoleEnum.Reader }, "access");
442+
var userFullName = viewModel.CurrentUser.FirstName + " " + viewModel.CurrentUser.LastName;
443+
var validationResult = await this.catalogueService.RequestAccessAsync(viewModel.CatalogueUrl, viewModel.CatalogueName, new CatalogueAccessRequestViewModel() { Message = viewModel.AccessRequestMessage, RoleId = (int)RoleEnum.Reader, EmailAddress = viewModel.CurrentUser.EmailAddress, UserFullName = userFullName }, "access");
443444

444445
if (validationResult.IsValid)
445446
{
@@ -521,7 +522,8 @@ public async Task<IActionResult> RequestPermission(CatalogueRequestAccessViewMod
521522
{
522523
if (this.ModelState.IsValid)
523524
{
524-
var validationResult = await this.catalogueService.RequestAccessAsync(viewModel.CatalogueUrl, new CatalogueAccessRequestViewModel() { Message = viewModel.AccessRequestMessage, RoleId = (int)RoleEnum.Previewer }, "permission");
525+
var userFullName = viewModel.CurrentUser.FirstName + " " + viewModel.CurrentUser.LastName;
526+
var validationResult = await this.catalogueService.RequestAccessAsync(viewModel.CatalogueUrl, viewModel.CatalogueName, new CatalogueAccessRequestViewModel() { Message = viewModel.AccessRequestMessage, RoleId = (int)RoleEnum.Previewer, EmailAddress = viewModel.CurrentUser.EmailAddress, UserFullName = userFullName }, "permission");
525527

526528
if (validationResult.IsValid)
527529
{
@@ -555,7 +557,9 @@ public async Task<IActionResult> RequestPreviewAccess(CatalogueRequestAccessView
555557
{
556558
if (this.ModelState.IsValid)
557559
{
558-
var validationResult = await this.catalogueService.RequestAccessAsync(viewModel.CatalogueUrl, new CatalogueAccessRequestViewModel() { Message = viewModel.AccessRequestMessage, RoleId = (int)RoleEnum.Previewer }, "access");
560+
var userFullName = viewModel.CurrentUser.FirstName + " " + viewModel.CurrentUser.LastName;
561+
562+
var validationResult = await this.catalogueService.RequestAccessAsync(viewModel.CatalogueUrl, viewModel.CatalogueName, new CatalogueAccessRequestViewModel() { Message = viewModel.AccessRequestMessage, RoleId = (int)RoleEnum.Previewer, EmailAddress = viewModel.CurrentUser.EmailAddress, UserFullName = userFullName }, "access");
559563

560564
if (validationResult.IsValid)
561565
{

LearningHub.Nhs.WebUI/Interfaces/ICatalogueService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ public interface ICatalogueService
6969
/// The RequestAccessAsync.
7070
/// </summary>
7171
/// <param name="reference">The catalogue reference.</param>
72+
/// <param name="catalogueName">The catalogue name.</param>
7273
/// <param name="vm">The view model.</param>
7374
/// <param name="accessType">The accessType.</param>
7475
/// <returns>The task.</returns>
75-
Task<LearningHubValidationResult> RequestAccessAsync(string reference, CatalogueAccessRequestViewModel vm, string accessType);
76+
Task<LearningHubValidationResult> RequestAccessAsync(string reference, string catalogueName, CatalogueAccessRequestViewModel vm, string accessType);
7677

7778
/// <summary>
7879
/// The InviteUserAsync.

LearningHub.Nhs.WebUI/Services/CatalogueService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,13 @@ public async Task<CatalogueAccessRequestViewModel> GetLatestCatalogueAccessReque
269269
/// The RequestAccessAsync.
270270
/// </summary>
271271
/// <param name="reference">The catalogue reference.</param>
272+
/// <param name="catalogueName">The catalogue catalogueName.</param>
272273
/// <param name="vm">The view model.</param>
273274
/// <param name="accessType">The accessType.</param>
274275
/// <returns>The task.</returns>
275-
public async Task<LearningHubValidationResult> RequestAccessAsync(string reference, CatalogueAccessRequestViewModel vm, string accessType)
276+
public async Task<LearningHubValidationResult> RequestAccessAsync(string reference, string catalogueName, CatalogueAccessRequestViewModel vm, string accessType)
276277
{
277-
var request = $"Catalogue/RequestAccess/{reference}/{accessType}";
278+
var request = $"Catalogue/RequestAccess/{reference}/{catalogueName}/{accessType}";
278279

279280
var client = await this.OpenApiHttpClient.GetClientAsync();
280281
var content = new StringContent(JsonConvert.SerializeObject(vm), Encoding.UTF8, "application/json");

MessagingService/LearningHub.Nhs.MessagingService/Services/GovNotifyService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ public async Task<GovNotifyResponse> SendEmailAsync(string email, string templat
4343
{
4444
var normalisedPersonlisation = new Dictionary<string, dynamic>();
4545
if (personalisation != null)
46+
{
47+
foreach (var item in personalisation)
4648
{
47-
foreach (var item in personalisation)
49+
if (item.Value is JsonElement element)
50+
{
51+
normalisedPersonlisation[item.Key] = element.ToString();
52+
}
53+
else
4854
{
49-
if (item.Value is JsonElement element)
50-
{
51-
normalisedPersonlisation[item.Key] = element.ToString();
52-
}
53-
else
54-
{
55-
normalisedPersonlisation[item.Key] = item.Value;
56-
}
55+
normalisedPersonlisation[item.Key] = item.Value;
5756
}
5857
}
58+
}
5959

6060
var response = await this.client.SendEmailAsync(email, templateId, normalisedPersonlisation);
6161
return new GovNotifyResponse

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.49" />
2021
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
2122
</ItemGroup>
2223

OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/Repositories/Hierarchy/ICatalogueAccessRequestRepository.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
namespace LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories.Hierarchy
22
{
3+
using System.Collections.Generic;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using LearningHub.Nhs.Models.Entities.Hierarchy;
7+
using LearningHub.Nhs.Models.Hierarchy;
68

79
/// <summary>
810
/// The ICatalogueAccessRequestRepository interface.
@@ -42,5 +44,19 @@ Task CreateCatalogueAccessRequestAsync(
4244
int roleId,
4345
string catalogueManageAccessUrl,
4446
string accessType);
47+
48+
/// <summary>
49+
/// The GetCatalogueAdminDetailsAsync.
50+
/// </summary>
51+
/// <param name="currentUserId">The currentUserId.</param>
52+
/// <param name="reference">The reference.</param>
53+
/// <param name="roleId">The roleId.</param>
54+
/// <param name="accessType">The accessType.</param>
55+
/// <returns>The task.</returns>
56+
Task<List<CatalogueAdminViewModel>> GetCatalogueAdminDetailsAsync(
57+
int currentUserId,
58+
string reference,
59+
int roleId,
60+
string accessType);
4561
}
4662
}

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/LearningHubDbContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace LearningHub.Nhs.OpenApi.Repositories.EntityFramework
1919
using LearningHub.Nhs.Models.Resource.ResourceDisplay;
2020
using LearningHub.Nhs.Models.User;
2121
using Microsoft.EntityFrameworkCore;
22+
using CatalogueAdminViewModel = LearningHub.Nhs.Models.Hierarchy.CatalogueAdminViewModel;
2223
using Event = LearningHub.Nhs.Models.Entities.Analytics.Event;
2324

2425
/// <summary>
@@ -393,6 +394,11 @@ public LearningHubDbContextOptions Options
393394
public virtual DbSet<NodeViewModel> NodeViewModel { get; set; }
394395

395396

397+
/// <summary>
398+
/// Gets or sets the CatalogueAdminViewModel.
399+
/// </summary>
400+
public virtual DbSet<CatalogueAdminViewModel> CatalogueAdminViewModel { get; set; }
401+
396402
/// <summary>
397403
/// Gets or sets the NodePathNodeViewModel.
398404
/// </summary>

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<PackageReference Include="AutoMapper" Version="10.1.1" />
2525
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
2626
<PackageReference Include="IdentityModel" Version="4.6.0" />
27+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.49" />
2728
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
2829
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.20" />
2930
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />

0 commit comments

Comments
 (0)