- @if(@Model.Resources.Resources != null)
+ @if (@Model.Resources.Resources != null)
{
@foreach (var resource in Model.Resources.Resources)
{
From 20ca42e811541d20ac6aac590b235b3184bb0dea Mon Sep 17 00:00:00 2001
From: AnjuJose011 <154979799+AnjuJose011@users.noreply.github.com>
Date: Thu, 10 Jul 2025 07:47:24 +0100
Subject: [PATCH 02/27] TD-5727
---
LearningHub.Nhs.WebUI/Controllers/ContributeController.cs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs b/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
index fc3b7f76a..f4632b29e 100644
--- a/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
@@ -28,6 +28,7 @@ public class ContributeController : BaseController
private readonly IFileService fileService;
private readonly IResourceService resourceService;
private readonly IUserService userService;
+ private readonly IUserGroupService userGroupService;
///
/// Initializes a new instance of the class.
@@ -37,6 +38,7 @@ public class ContributeController : BaseController
/// Logger.
/// Settings.
/// User service.
+ /// userGroupService.
/// File service.
/// Resource service.
/// Azure media service.
@@ -48,6 +50,7 @@ public ContributeController(
ILogger logger,
IOptions settings,
IUserService userService,
+ IUserGroupService userGroupService,
IFileService fileService,
IResourceService resourceService,
IAzureMediaService azureMediaService,
@@ -58,6 +61,7 @@ public ContributeController(
this.authConfig = authConfig;
this.userService = userService;
+ this.userGroupService = userGroupService;
this.fileService = fileService;
this.resourceService = resourceService;
this.azureMediaService = azureMediaService;
@@ -167,7 +171,8 @@ public async Task CreateVersion(int resourceId)
[Route("my-contributions/{selectedTab}/{catalogueId}/{nodeId}")]
public async Task MyContributions()
{
- if ((this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser")) && !await this.resourceService.UserHasPublishedResourcesAsync())
+ bool usergroup = await this.userGroupService.UserHasCatalogueContributionPermission();
+ if ((this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser")) || (!usergroup && (!await this.resourceService.UserHasPublishedResourcesAsync())))
{
return this.RedirectToAction("AccessDenied", "Home");
}
From 19d6cfc693bf9d648c2f8f9623dfe0761a69379d Mon Sep 17 00:00:00 2001
From: AnjuJose011 <154979799+AnjuJose011@users.noreply.github.com>
Date: Thu, 10 Jul 2025 07:52:10 +0100
Subject: [PATCH 03/27] TD-5727
---
LearningHub.Nhs.WebUI/Controllers/ContributeController.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs b/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
index f4632b29e..27ae615ce 100644
--- a/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs
@@ -171,8 +171,8 @@ public async Task CreateVersion(int resourceId)
[Route("my-contributions/{selectedTab}/{catalogueId}/{nodeId}")]
public async Task MyContributions()
{
- bool usergroup = await this.userGroupService.UserHasCatalogueContributionPermission();
- if ((this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser")) || (!usergroup && (!await this.resourceService.UserHasPublishedResourcesAsync())))
+ bool catalogueContributionPermission = await this.userGroupService.UserHasCatalogueContributionPermission();
+ if ((this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser")) || (!catalogueContributionPermission && (!await this.resourceService.UserHasPublishedResourcesAsync())))
{
return this.RedirectToAction("AccessDenied", "Home");
}
From 247ef8fdfd67c550cff080c65ce7ce45b69e7378 Mon Sep 17 00:00:00 2001
From: Phil-NHS
Date: Fri, 18 Jul 2025 15:56:45 +0100
Subject: [PATCH 04/27] TD-5829: Introduced Shared Project refactored code
shared with Blazor into as first code to become shared.
---
.../Configuration/FindwiseSettingsPublic.cs | 12 +++--
.../Configuration/PublicSettings.cs | 31 ++++++++++++
.../Helpers/ResourceAccessLevelHelper.cs | 5 +-
.../Helpers/ResourceTypeEnumMoodle.cs | 2 +-
.../Helpers/SearchHelper.cs | 2 +-
.../Helpers/UtilityHelper.cs | 1 +
.../Configuration/IFindwiseSettingsPublic.cs | 29 +++++++++++
.../Configuration/IPublicSettings.cs | 28 +++++++++++
.../Interfaces/Http/IAPIHttpClient.cs | 18 +++++++
.../Interfaces/Http/ILearningHubHttpClient.cs | 22 ++++++++
.../Interfaces/Http/IUserAPIHttpClient.cs | 22 ++++++++
.../Interfaces/Services}/IProviderService.cs | 2 +-
.../Interfaces/Services}/ISearchService.cs | 6 +--
.../LearningHub.Nhs.Shared.csproj | 19 +++++++
.../Search/SearchActionCatalogueClickModel.cs | 2 +-
.../Models/Search/SearchFormActionTypeEnum.cs | 2 +-
.../Models/Search/SearchRequestViewModel.cs | 4 +-
.../Models/Search/SearchResultPagingModel.cs | 2 +-
.../Models/Search/SearchResultViewModel.cs | 2 +-
.../Services/BaseService.cs | 4 +-
.../Services/ProviderService.cs | 5 +-
.../Services/SearchService.cs | 50 +++++++++++--------
LearningHub.Nhs.WebUI.sln | 23 ++++++++-
.../Configuration/Settings.cs | 3 +-
.../Controllers/Api/ProviderController.cs | 1 +
.../Controllers/Api/SearchController.cs | 5 ++
.../Controllers/CatalogueController.cs | 6 ++-
.../Controllers/LogoutController.cs | 5 +-
.../Controllers/SearchController.cs | 4 +-
.../Helpers/LearningHubApiFacade.cs | 2 +-
.../Interfaces/ILearningHubHttpClient.cs | 17 -------
.../Interfaces/IUserApiHttpClient.cs | 17 -------
.../LearningHub.Nhs.WebUI.csproj | 4 ++
.../Catalogue/CatalogueIndexViewModel.cs | 2 +-
.../Services/ActivityService.cs | 2 +
.../Services/BaseHttpClient.cs | 3 +-
.../Services/BoomarkService.cs | 2 +
LearningHub.Nhs.WebUI/Services/CardService.cs | 2 +
.../Services/CatalogueService.cs | 2 +
.../Services/ContentService.cs | 4 +-
.../Services/ContributeService.cs | 2 +
.../Services/CountryService.cs | 2 +
.../Services/DashboardService.cs | 2 +
.../Services/DetectJsLogService.cs | 2 +
.../Services/GradeService.cs | 2 +
.../Services/HierarchyService.cs | 2 +
.../Services/InternalSystemService.cs | 2 +
.../Services/JobRoleService.cs | 2 +
.../Services/LearningHubHttpClient.cs | 1 +
.../Services/LocationService.cs | 2 +
.../Services/LoginWizardService.cs | 2 +
.../Services/MyLearningService.cs | 2 +
.../Services/NotificationService.cs | 2 +
.../Services/PartialFileUploadService.cs | 2 +
.../Services/RatingService.cs | 2 +
.../Services/RegionService.cs | 2 +
.../Services/ResourceService.cs | 2 +
.../Services/RoadMapService.cs | 2 +
LearningHub.Nhs.WebUI/Services/RoleService.cs | 2 +
.../Services/SpecialtyService.cs | 2 +
.../Services/TermsAndConditionsService.cs | 2 +
.../Services/UserApiHttpClient.cs | 1 +
.../Services/UserGroupService.cs | 2 +
LearningHub.Nhs.WebUI/Services/UserService.cs | 2 +
.../Startup/ServiceMappings.cs | 3 ++
.../_AccountCreationGradePaging.cshtml | 2 +-
.../_AccountCreationJobRolePaging.cshtml | 2 +-
.../_AccountCreationRegionPaging.cshtml | 2 +-
.../_AccountCreationSpecialtyPaging.cshtml | 2 +-
.../_AccountCreationWorkPlacePaging.cshtml | 2 +-
.../Views/Bookmark/_BookmarkItem.cshtml | 1 +
.../Views/Catalogue/Index.cshtml | 1 +
.../Views/Catalogue/_ContentStructure.cshtml | 1 +
.../Views/Catalogue/_SearchPagination.cshtml | 2 +-
.../Catalogue/_SearchWithinCatalogue.cshtml | 2 +-
.../Views/Home/_CatalogueCard.cshtml | 1 +
.../Views/Home/_CourseEnrolled.cshtml | 1 +
.../Views/Home/_ResourceCard.cshtml | 1 +
.../MyLearning/LearningCertificate.cshtml | 1 +
.../MyLearning/_ActivityTablePaging.cshtml | 2 +-
.../Views/Resource/Resource.cshtml | 1 +
.../Resource/_ResourceInformation.cshtml | 1 +
.../Views/Resource/_ResourceItem.cshtml | 1 +
.../Views/Search/Index.cshtml | 2 +-
.../Views/Search/_CataloguePagination.cshtml | 2 +-
.../Search/_CatalogueSearchResult.cshtml | 2 +-
.../Views/Search/_ResourceFilter.cshtml | 2 +-
.../Views/Search/_ResourcePagination.cshtml | 2 +-
.../Views/Search/_ResourceSearchResult.cshtml | 5 +-
.../Views/Search/_SubmitFeedback.cshtml | 2 +-
.../Views/Shared/_TwitterFeeds.cshtml | 2 +-
91 files changed, 360 insertions(+), 108 deletions(-)
rename LearningHub.Nhs.WebUI/Configuration/FindwiseSettings.cs => LearningHub.Nhs.Shared/Configuration/FindwiseSettingsPublic.cs (53%)
create mode 100644 LearningHub.Nhs.Shared/Configuration/PublicSettings.cs
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Helpers/ResourceAccessLevelHelper.cs (89%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Helpers/ResourceTypeEnumMoodle.cs (96%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Helpers/SearchHelper.cs (96%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Helpers/UtilityHelper.cs (99%)
create mode 100644 LearningHub.Nhs.Shared/Interfaces/Configuration/IFindwiseSettingsPublic.cs
create mode 100644 LearningHub.Nhs.Shared/Interfaces/Configuration/IPublicSettings.cs
create mode 100644 LearningHub.Nhs.Shared/Interfaces/Http/IAPIHttpClient.cs
create mode 100644 LearningHub.Nhs.Shared/Interfaces/Http/ILearningHubHttpClient.cs
create mode 100644 LearningHub.Nhs.Shared/Interfaces/Http/IUserAPIHttpClient.cs
rename {LearningHub.Nhs.WebUI/Interfaces => LearningHub.Nhs.Shared/Interfaces/Services}/IProviderService.cs (95%)
rename {LearningHub.Nhs.WebUI/Interfaces => LearningHub.Nhs.Shared/Interfaces/Services}/ISearchService.cs (97%)
create mode 100644 LearningHub.Nhs.Shared/LearningHub.Nhs.Shared.csproj
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Models/Search/SearchActionCatalogueClickModel.cs (88%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Models/Search/SearchFormActionTypeEnum.cs (96%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Models/Search/SearchRequestViewModel.cs (95%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Models/Search/SearchResultPagingModel.cs (92%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Models/Search/SearchResultViewModel.cs (98%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Services/BaseService.cs (92%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Services/ProviderService.cs (97%)
rename {LearningHub.Nhs.WebUI => LearningHub.Nhs.Shared}/Services/SearchService.cs (96%)
delete mode 100644 LearningHub.Nhs.WebUI/Interfaces/ILearningHubHttpClient.cs
delete mode 100644 LearningHub.Nhs.WebUI/Interfaces/IUserApiHttpClient.cs
diff --git a/LearningHub.Nhs.WebUI/Configuration/FindwiseSettings.cs b/LearningHub.Nhs.Shared/Configuration/FindwiseSettingsPublic.cs
similarity index 53%
rename from LearningHub.Nhs.WebUI/Configuration/FindwiseSettings.cs
rename to LearningHub.Nhs.Shared/Configuration/FindwiseSettingsPublic.cs
index 683d5b4c9..830351eda 100644
--- a/LearningHub.Nhs.WebUI/Configuration/FindwiseSettings.cs
+++ b/LearningHub.Nhs.Shared/Configuration/FindwiseSettingsPublic.cs
@@ -1,9 +1,15 @@
-namespace LearningHub.Nhs.WebUI.Configuration
+namespace LearningHub.Nhs.Shared.Configuration
{
+ using LearningHub.Nhs.Shared.Interfaces.Configuration;
///
- /// Defines the .
+ /// Represents a public-facing set of configuration values for Findwise search,
+ /// intended to be safely exposed to client-side applications or public APIs.
+ ///
+ ///
+ /// Contains only non-sensitive data such as page sizes for various search types.
+ ///
///
- public class FindwiseSettings
+ public class FindwiseSettingsPublic : IFindwiseSettingsPublic
{
///
/// Gets or sets the ResourceSearchPageSize.
diff --git a/LearningHub.Nhs.Shared/Configuration/PublicSettings.cs b/LearningHub.Nhs.Shared/Configuration/PublicSettings.cs
new file mode 100644
index 000000000..c8607094f
--- /dev/null
+++ b/LearningHub.Nhs.Shared/Configuration/PublicSettings.cs
@@ -0,0 +1,31 @@
+namespace LearningHub.Nhs.Shared.Configuration
+{
+ using LearningHub.Nhs.Shared.Interfaces.Configuration;
+ ///
+ /// Represents configuration values that are safe to expose to clientside frontend applications
+ /// (such as Blazor WebAssembly) or public-facing APIs.
+ ///
+ ///
+ /// Implements and contains only non-sensitive, non-secret
+ /// values such as public API endpoints and pagination settings. This separation ensures
+ /// that secure or private configuration data is not inadvertently exposed to clients.
+ ///
+ ///
+ public class PublicSettings : IPublicSettings
+ {
+ ///
+ public string LearningHubApiUrl { get; set; }
+
+ ///
+ public int ResourceSearchPageSize { get; set; }
+
+ ///
+ public int CatalogueSearchPageSize { get; set; }
+
+ ///
+ public int AllCatalogueSearchPageSize { get; set; }
+
+ ///
+ public IFindwiseSettingsPublic FindwiseSettings { get; set; }
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Helpers/ResourceAccessLevelHelper.cs b/LearningHub.Nhs.Shared/Helpers/ResourceAccessLevelHelper.cs
similarity index 89%
rename from LearningHub.Nhs.WebUI/Helpers/ResourceAccessLevelHelper.cs
rename to LearningHub.Nhs.Shared/Helpers/ResourceAccessLevelHelper.cs
index e03200172..45eeec5ec 100644
--- a/LearningHub.Nhs.WebUI/Helpers/ResourceAccessLevelHelper.cs
+++ b/LearningHub.Nhs.Shared/Helpers/ResourceAccessLevelHelper.cs
@@ -1,7 +1,6 @@
-namespace LearningHub.Nhs.WebUI.Helpers
+namespace LearningHub.Nhs.Shared.Helpers
{
using LearningHub.Nhs.Models.Enums;
- using Microsoft.AspNetCore.Mvc.Rendering;
///
/// Defines the .
@@ -11,7 +10,7 @@ public static class ResourceAccessLevelHelper
///
/// Get resource access level text.
///
- /// The htmlhelper.
+ /// The enum value to get display text for.
/// The .
public static string GetResourceAccessLevelText(this ResourceAccessibilityEnum resourceAccessibilityEnum)
{
diff --git a/LearningHub.Nhs.WebUI/Helpers/ResourceTypeEnumMoodle.cs b/LearningHub.Nhs.Shared/Helpers/ResourceTypeEnumMoodle.cs
similarity index 96%
rename from LearningHub.Nhs.WebUI/Helpers/ResourceTypeEnumMoodle.cs
rename to LearningHub.Nhs.Shared/Helpers/ResourceTypeEnumMoodle.cs
index e0601d156..741461664 100644
--- a/LearningHub.Nhs.WebUI/Helpers/ResourceTypeEnumMoodle.cs
+++ b/LearningHub.Nhs.Shared/Helpers/ResourceTypeEnumMoodle.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Helpers;
+namespace LearningHub.Nhs.Shared.Helpers;
///
/// Represents the types of resources available in Moodle.
diff --git a/LearningHub.Nhs.WebUI/Helpers/SearchHelper.cs b/LearningHub.Nhs.Shared/Helpers/SearchHelper.cs
similarity index 96%
rename from LearningHub.Nhs.WebUI/Helpers/SearchHelper.cs
rename to LearningHub.Nhs.Shared/Helpers/SearchHelper.cs
index c94eda513..f7d4bd593 100644
--- a/LearningHub.Nhs.WebUI/Helpers/SearchHelper.cs
+++ b/LearningHub.Nhs.Shared/Helpers/SearchHelper.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Helpers
+namespace LearningHub.Nhs.Shared.Helpers
{
using System.Collections.Generic;
using LearningHub.Nhs.Models.Enums;
diff --git a/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs b/LearningHub.Nhs.Shared/Helpers/UtilityHelper.cs
similarity index 99%
rename from LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs
rename to LearningHub.Nhs.Shared/Helpers/UtilityHelper.cs
index ef71191f9..b1c728eea 100644
--- a/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs
+++ b/LearningHub.Nhs.Shared/Helpers/UtilityHelper.cs
@@ -8,6 +8,7 @@
using HtmlAgilityPack;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Hierarchy;
+ using LearningHub.Nhs.Shared.Helpers;
using Microsoft.AspNetCore.Mvc.Rendering;
///
diff --git a/LearningHub.Nhs.Shared/Interfaces/Configuration/IFindwiseSettingsPublic.cs b/LearningHub.Nhs.Shared/Interfaces/Configuration/IFindwiseSettingsPublic.cs
new file mode 100644
index 000000000..e63a98039
--- /dev/null
+++ b/LearningHub.Nhs.Shared/Interfaces/Configuration/IFindwiseSettingsPublic.cs
@@ -0,0 +1,29 @@
+namespace LearningHub.Nhs.Shared.Interfaces.Configuration
+{
+ ///
+ /// Represents configuration values related to Findwise search that are safe to expose
+ /// to client-side applications or public-facing APIs.
+ ///
+ ///
+ /// This includes non-sensitive values such as page sizes for different types of search results.
+ /// It does not contain any secure credentials or internal service configuration.
+ ///
+ ///
+ public interface IFindwiseSettingsPublic
+ {
+ ///
+ /// Gets or sets the page size for resource search results.
+ ///
+ public int ResourceSearchPageSize { get; set; }
+
+ ///
+ /// Gets or sets the CatalogueSearchPageSize.
+ ///
+ public int CatalogueSearchPageSize { get; set; }
+
+ ///
+ /// Gets or sets the AllCatalogueSearchPageSize.
+ ///
+ public int AllCatalogueSearchPageSize { get; set; }
+ }
+}
diff --git a/LearningHub.Nhs.Shared/Interfaces/Configuration/IPublicSettings.cs b/LearningHub.Nhs.Shared/Interfaces/Configuration/IPublicSettings.cs
new file mode 100644
index 000000000..f81ef73af
--- /dev/null
+++ b/LearningHub.Nhs.Shared/Interfaces/Configuration/IPublicSettings.cs
@@ -0,0 +1,28 @@
+namespace LearningHub.Nhs.Shared.Interfaces.Configuration
+{
+ ///
+ /// Defines a contract for configuration data that is non-sensitive and safe to expose publicly
+ ///
+ ///
+ /// This interface exposes only data that is safe to be publicly consumed or shared,
+ /// such as API endpoint URLs or non-sensitive configuration values.
+ /// It explicitly excludes any private or sensitive information (e.g., authentication tokens,
+ /// credentials, or secret keys), which should be handled via separate interfaces or services.
+ ///
+ ///
+ ///
+ /// The data provided by this interface can be safely used in frontend technologies,
+ /// such as Blazor WebAssembly, JavaScript frameworks, or other client-side applications,
+ /// without risking exposure of sensitive information.
+ ///
+ ///
+ public interface IPublicSettings
+ {
+ ///
+ /// Gets or sets the LearningHubApiUrl.
+ ///
+ public string LearningHubApiUrl { get; set; }
+
+ public IFindwiseSettingsPublic FindwiseSettings { get; set; }
+ }
+}
diff --git a/LearningHub.Nhs.Shared/Interfaces/Http/IAPIHttpClient.cs b/LearningHub.Nhs.Shared/Interfaces/Http/IAPIHttpClient.cs
new file mode 100644
index 000000000..c65fe674b
--- /dev/null
+++ b/LearningHub.Nhs.Shared/Interfaces/Http/IAPIHttpClient.cs
@@ -0,0 +1,18 @@
+namespace LearningHub.Nhs.Shared.Interfaces.Http
+{
+ ///
+ /// Represents an HTTP client for a specific API.
+ ///
+ public interface IAPIHttpClient
+ {
+ ///
+ /// Gets the configured for the API.
+ ///
+ Task GetClientAsync();
+
+ ///
+ /// Gets the base URL of the API.
+ ///
+ string ApiUrl { get; }
+ }
+}
diff --git a/LearningHub.Nhs.Shared/Interfaces/Http/ILearningHubHttpClient.cs b/LearningHub.Nhs.Shared/Interfaces/Http/ILearningHubHttpClient.cs
new file mode 100644
index 000000000..68ebb245b
--- /dev/null
+++ b/LearningHub.Nhs.Shared/Interfaces/Http/ILearningHubHttpClient.cs
@@ -0,0 +1,22 @@
+namespace LearningHub.Nhs.Shared.Interfaces.Http
+{
+ ///
+ /// Marker interface for the LearningHub API HttpClient.
+ ///
+ ///
+ /// Inherits from to enable
+ /// dependency injection of a specific implementation configured with
+ /// different API endpoints or settings specific to LH API.
+ ///
+ ///
+ ///
+ /// Currently, this interface is empty and used solely to differentiate implementations
+ /// that connect to different endpoints via configuration, but it may be extended in the future
+ /// with LearningHub-specific functionality or properties.
+ ///
+ ///
+ public interface ILearningHubHttpClient : IAPIHttpClient
+ {
+
+ }
+}
diff --git a/LearningHub.Nhs.Shared/Interfaces/Http/IUserAPIHttpClient.cs b/LearningHub.Nhs.Shared/Interfaces/Http/IUserAPIHttpClient.cs
new file mode 100644
index 000000000..25ec29d70
--- /dev/null
+++ b/LearningHub.Nhs.Shared/Interfaces/Http/IUserAPIHttpClient.cs
@@ -0,0 +1,22 @@
+namespace LearningHub.Nhs.Shared.Interfaces.Http
+{
+ ///
+ /// Marker interface for the User API HttpClient.
+ ///
+ ///
+ /// Inherits from to enable
+ /// dependency injection of a specific implementation configured with
+ /// a user-related API endpoint or settings.
+ ///
+ ///
+ ///
+ /// This interface is currently empty and used solely to differentiate
+ /// implementations that connect to different endpoints via configuration.
+ /// It may be extended in the future with user-specific functionality or properties.
+ ///
+ ///
+ public interface IUserApiHttpClient : IAPIHttpClient
+ {
+
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Interfaces/IProviderService.cs b/LearningHub.Nhs.Shared/Interfaces/Services/IProviderService.cs
similarity index 95%
rename from LearningHub.Nhs.WebUI/Interfaces/IProviderService.cs
rename to LearningHub.Nhs.Shared/Interfaces/Services/IProviderService.cs
index 528b7a4ec..acd3321ce 100644
--- a/LearningHub.Nhs.WebUI/Interfaces/IProviderService.cs
+++ b/LearningHub.Nhs.Shared/Interfaces/Services/IProviderService.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Interfaces
+namespace LearningHub.Nhs.Shared.Interfaces.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
diff --git a/LearningHub.Nhs.WebUI/Interfaces/ISearchService.cs b/LearningHub.Nhs.Shared/Interfaces/Services/ISearchService.cs
similarity index 97%
rename from LearningHub.Nhs.WebUI/Interfaces/ISearchService.cs
rename to LearningHub.Nhs.Shared/Interfaces/Services/ISearchService.cs
index 3f083bc38..8dba5d177 100644
--- a/LearningHub.Nhs.WebUI/Interfaces/ISearchService.cs
+++ b/LearningHub.Nhs.Shared/Interfaces/Services/ISearchService.cs
@@ -1,10 +1,10 @@
-namespace LearningHub.Nhs.WebUI.Interfaces
+namespace LearningHub.Nhs.Shared.Interfaces.Services
{
+ using LearningHub.Nhs.Shared.Models.Search;
+ using LearningHub.Nhs.Models.Search.SearchClick;
using System.Security.Principal;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Search;
- using LearningHub.Nhs.Models.Search.SearchClick;
- using LearningHub.Nhs.WebUI.Models.Search;
///
/// Defines the .
diff --git a/LearningHub.Nhs.Shared/LearningHub.Nhs.Shared.csproj b/LearningHub.Nhs.Shared/LearningHub.Nhs.Shared.csproj
new file mode 100644
index 000000000..ea7db4aa9
--- /dev/null
+++ b/LearningHub.Nhs.Shared/LearningHub.Nhs.Shared.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LearningHub.Nhs.WebUI/Models/Search/SearchActionCatalogueClickModel.cs b/LearningHub.Nhs.Shared/Models/Search/SearchActionCatalogueClickModel.cs
similarity index 88%
rename from LearningHub.Nhs.WebUI/Models/Search/SearchActionCatalogueClickModel.cs
rename to LearningHub.Nhs.Shared/Models/Search/SearchActionCatalogueClickModel.cs
index a85e334d5..1129dd78e 100644
--- a/LearningHub.Nhs.WebUI/Models/Search/SearchActionCatalogueClickModel.cs
+++ b/LearningHub.Nhs.Shared/Models/Search/SearchActionCatalogueClickModel.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Models
+namespace LearningHub.Nhs.Shared.Models.Search
{
using LearningHub.Nhs.Models.Search;
diff --git a/LearningHub.Nhs.WebUI/Models/Search/SearchFormActionTypeEnum.cs b/LearningHub.Nhs.Shared/Models/Search/SearchFormActionTypeEnum.cs
similarity index 96%
rename from LearningHub.Nhs.WebUI/Models/Search/SearchFormActionTypeEnum.cs
rename to LearningHub.Nhs.Shared/Models/Search/SearchFormActionTypeEnum.cs
index 4fc86ce57..837a0e6bc 100644
--- a/LearningHub.Nhs.WebUI/Models/Search/SearchFormActionTypeEnum.cs
+++ b/LearningHub.Nhs.Shared/Models/Search/SearchFormActionTypeEnum.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Models.Search
+namespace LearningHub.Nhs.Shared.Models.Search
{
///
/// Defines the SearchFormActionTypeEnum.
diff --git a/LearningHub.Nhs.WebUI/Models/Search/SearchRequestViewModel.cs b/LearningHub.Nhs.Shared/Models/Search/SearchRequestViewModel.cs
similarity index 95%
rename from LearningHub.Nhs.WebUI/Models/Search/SearchRequestViewModel.cs
rename to LearningHub.Nhs.Shared/Models/Search/SearchRequestViewModel.cs
index 8b4d5de04..a59b832f9 100644
--- a/LearningHub.Nhs.WebUI/Models/Search/SearchRequestViewModel.cs
+++ b/LearningHub.Nhs.Shared/Models/Search/SearchRequestViewModel.cs
@@ -1,8 +1,8 @@
-namespace LearningHub.Nhs.WebUI.Models.Search
+namespace LearningHub.Nhs.Shared.Models.Search
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
- using Microsoft.AspNetCore.Mvc;
+ using Microsoft.AspNetCore.Mvc;//qqqq
///
/// Defines the .
diff --git a/LearningHub.Nhs.WebUI/Models/Search/SearchResultPagingModel.cs b/LearningHub.Nhs.Shared/Models/Search/SearchResultPagingModel.cs
similarity index 92%
rename from LearningHub.Nhs.WebUI/Models/Search/SearchResultPagingModel.cs
rename to LearningHub.Nhs.Shared/Models/Search/SearchResultPagingModel.cs
index 9082444d4..aa3954ef9 100644
--- a/LearningHub.Nhs.WebUI/Models/Search/SearchResultPagingModel.cs
+++ b/LearningHub.Nhs.Shared/Models/Search/SearchResultPagingModel.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Models.Search
+namespace LearningHub.Nhs.Shared.Models.Search
{
using LearningHub.Nhs.Models.Paging;
diff --git a/LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs b/LearningHub.Nhs.Shared/Models/Search/SearchResultViewModel.cs
similarity index 98%
rename from LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs
rename to LearningHub.Nhs.Shared/Models/Search/SearchResultViewModel.cs
index 543a50e5f..a9d189677 100644
--- a/LearningHub.Nhs.WebUI/Models/Search/SearchResultViewModel.cs
+++ b/LearningHub.Nhs.Shared/Models/Search/SearchResultViewModel.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Models.Search
+namespace LearningHub.Nhs.Shared.Models.Search
{
using System;
using LearningHub.Nhs.Models.Paging;
diff --git a/LearningHub.Nhs.WebUI/Services/BaseService.cs b/LearningHub.Nhs.Shared/Services/BaseService.cs
similarity index 92%
rename from LearningHub.Nhs.WebUI/Services/BaseService.cs
rename to LearningHub.Nhs.Shared/Services/BaseService.cs
index 87d4cfc79..7078f9838 100644
--- a/LearningHub.Nhs.WebUI/Services/BaseService.cs
+++ b/LearningHub.Nhs.Shared/Services/BaseService.cs
@@ -1,6 +1,6 @@
-namespace LearningHub.Nhs.WebUI.Services
+namespace LearningHub.Nhs.Shared.Services
{
- using LearningHub.Nhs.WebUI.Interfaces;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using Microsoft.Extensions.Logging;
///
diff --git a/LearningHub.Nhs.WebUI/Services/ProviderService.cs b/LearningHub.Nhs.Shared/Services/ProviderService.cs
similarity index 97%
rename from LearningHub.Nhs.WebUI/Services/ProviderService.cs
rename to LearningHub.Nhs.Shared/Services/ProviderService.cs
index 44a91495b..c2c31b4b1 100644
--- a/LearningHub.Nhs.WebUI/Services/ProviderService.cs
+++ b/LearningHub.Nhs.Shared/Services/ProviderService.cs
@@ -1,4 +1,4 @@
-namespace LearningHub.Nhs.WebUI.Services
+namespace LearningHub.Nhs.Shared.Services
{
using System;
using System.Collections.Generic;
@@ -6,7 +6,8 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.Provider;
- using LearningHub.Nhs.WebUI.Interfaces;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/SearchService.cs b/LearningHub.Nhs.Shared/Services/SearchService.cs
similarity index 96%
rename from LearningHub.Nhs.WebUI/Services/SearchService.cs
rename to LearningHub.Nhs.Shared/Services/SearchService.cs
index 40feaf6fb..f08a3cd9b 100644
--- a/LearningHub.Nhs.WebUI/Services/SearchService.cs
+++ b/LearningHub.Nhs.Shared/Services/SearchService.cs
@@ -1,33 +1,37 @@
-namespace LearningHub.Nhs.WebUI.Services
+namespace LearningHub.Nhs.Shared.Services
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http;
- using System.Security.Principal;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Web;
using HtmlAgilityPack;
using LearningHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Search;
using LearningHub.Nhs.Models.Search.SearchClick;
- using LearningHub.Nhs.WebUI.Configuration;
+ using LearningHub.Nhs.Shared.Configuration;
+ using LearningHub.Nhs.Shared.Helpers;
+ using LearningHub.Nhs.Shared.Interfaces.Configuration;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
+ using LearningHub.Nhs.Shared.Models.Search;
using LearningHub.Nhs.WebUI.Helpers;
- using LearningHub.Nhs.WebUI.Interfaces;
- using LearningHub.Nhs.WebUI.Models.Search;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net.Http;
+ using System.Security.Principal;
+ using System.Text;
+ using System.Text.RegularExpressions;
+ using System.Threading.Tasks;
+ using System.Web;
///
/// Defines the .
///
public class SearchService : BaseService, ISearchService
{
- private readonly Settings settings;
+ ///private readonly Settings settings;qqqq
+ private readonly IPublicSettings publicSettings;
private IProviderService providerService;
///
@@ -37,10 +41,14 @@ public class SearchService : BaseService, ISearchService
/// Provider service.
/// Logger.
/// Settings.
- public SearchService(ILearningHubHttpClient learningHubHttpClient, IProviderService providerService, ILogger logger, IOptions settings)
+ public SearchService(ILearningHubHttpClient learningHubHttpClient,
+ IProviderService providerService,
+ ILogger logger,
+ IOptions publicSettings)
: base(learningHubHttpClient, logger)
{
- this.settings = settings.Value;
+ this.publicSettings = publicSettings.Value;
+ this.providerService = providerService;
this.providerService = providerService;
}
@@ -67,8 +75,8 @@ public async Task PerformSearch(IPrincipal user, SearchRe
var suggestedCatalogue = string.Empty;
var suggestedResource = string.Empty;
- var resourceSearchPageSize = this.settings.FindwiseSettings.ResourceSearchPageSize;
- var catalogueSearchPageSize = this.settings.FindwiseSettings.CatalogueSearchPageSize;
+ var resourceSearchPageSize = this.publicSettings.FindwiseSettings.ResourceSearchPageSize;
+ var catalogueSearchPageSize = this.publicSettings.FindwiseSettings.CatalogueSearchPageSize;
var resourceSearchRequestModel = new SearchRequestModel
{
@@ -253,8 +261,8 @@ public async Task PerformSearch(IPrincipal user, SearchRe
public async Task RegisterSearchEventsAsync(SearchRequestViewModel search, SearchFormActionTypeEnum action, int resourceCount = 0, int catalogueCount = 0)
{
var eventId = 0;
- var resourceSearchPageSize = this.settings.FindwiseSettings.ResourceSearchPageSize;
- var catalogueSearchPageSize = this.settings.FindwiseSettings.CatalogueSearchPageSize;
+ var resourceSearchPageSize = this.publicSettings.FindwiseSettings.ResourceSearchPageSize;
+ var catalogueSearchPageSize = this.publicSettings.FindwiseSettings.CatalogueSearchPageSize;
var sortBy = search.Sortby.HasValue ? (SearchSortTypeEnum)search.Sortby : SearchSortTypeEnum.Relevance;
@@ -511,7 +519,7 @@ public async Task SubmitFeedbackAsync(SearchFeedBackModel model)
int createId = 0;
var client = await this.LearningHubHttpClient.GetClientAsync();
- var request = this.settings.LearningHubApiUrl + "Search/SubmitFeedback";
+ var request = this.publicSettings.LearningHubApiUrl + "Search/SubmitFeedback";
var content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
var response = await client.PostAsync(request, content).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI.sln b/LearningHub.Nhs.WebUI.sln
index 55cce01f0..c88094381 100644
--- a/LearningHub.Nhs.WebUI.sln
+++ b/LearningHub.Nhs.WebUI.sln
@@ -4,11 +4,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LearningHub.Nhs.WebUI", "LearningHub.Nhs.WebUI\LearningHub.Nhs.WebUI.csproj", "{16BBF937-C1E9-4240-B56E-20E3E5FA2005}"
+ ProjectSection(ProjectDependencies) = postProject
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E} = {9F1B0470-E809-49FE-A6E8-152C7EBD012E}
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B5D48B6A-D4A7-494E-89C0-64428232D242}"
ProjectSection(SolutionItems) = preProject
- Directory.Build.props = Directory.Build.props
- Directory.Packages.props = Directory.Packages.props
+ .editorconfig = .editorconfig
+ global.json = global.json
StyleCop.ruleset = StyleCop.ruleset
EndProjectSection
EndProject
@@ -17,6 +20,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MigrationTool", "MigrationTool", "{94676CCE-A38B-4FAF-905E-CE85CE95845E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LearningHub.Nhs.Api", "WebAPI\LearningHub.Nhs.API\LearningHub.Nhs.Api.csproj", "{21F15E96-314F-4F39-822F-C2568CDC4A5A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E} = {9F1B0470-E809-49FE-A6E8-152C7EBD012E}
+ EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LearningHub.Nhs.Api.Shared", "WebAPI\LearningHub.Nhs.Api.Shared\LearningHub.Nhs.Api.Shared.csproj", "{719833B9-EC79-48F2-9123-C4DF111AE9AA}"
EndProject
@@ -51,6 +57,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AdminUI", "AdminUI", "{9642BC19-BAE7-45A9-B4F2-8D7529786CDC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LearningHub.Nhs.AdminUI", "AdminUI\LearningHub.Nhs.AdminUI\LearningHub.Nhs.AdminUI.csproj", "{1C97A3C2-73E8-4AFF-92EF-F65B4899FADB}"
+ ProjectSection(ProjectDependencies) = postProject
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E} = {9F1B0470-E809-49FE-A6E8-152C7EBD012E}
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenAPI", "OpenAPI", "{66ED23A2-F15A-4ECB-A84D-736C95BEFC61}"
EndProject
@@ -82,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LearningHub.Nhs.ReportApi.S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LearningHub.Nhs.WebUI.AutomatedUiTests", "LearningHub.Nhs.WebUI.AutomatedUiTests\LearningHub.Nhs.WebUI.AutomatedUiTests.csproj", "{A84EC50B-2B01-4819-A2B1-BD867B7595CA}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LearningHub.Nhs.Shared", "LearningHub.Nhs.Shared\LearningHub.Nhs.Shared.csproj", "{9F1B0470-E809-49FE-A6E8-152C7EBD012E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -346,6 +357,14 @@ Global
{A84EC50B-2B01-4819-A2B1-BD867B7595CA}.Release|Any CPU.Build.0 = Release|Any CPU
{A84EC50B-2B01-4819-A2B1-BD867B7595CA}.Release|x64.ActiveCfg = Release|Any CPU
{A84EC50B-2B01-4819-A2B1-BD867B7595CA}.Release|x64.Build.0 = Release|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Debug|x64.Build.0 = Debug|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Release|x64.ActiveCfg = Release|Any CPU
+ {9F1B0470-E809-49FE-A6E8-152C7EBD012E}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/LearningHub.Nhs.WebUI/Configuration/Settings.cs b/LearningHub.Nhs.WebUI/Configuration/Settings.cs
index ccb06c921..8596f775a 100644
--- a/LearningHub.Nhs.WebUI/Configuration/Settings.cs
+++ b/LearningHub.Nhs.WebUI/Configuration/Settings.cs
@@ -1,6 +1,7 @@
namespace LearningHub.Nhs.WebUI.Configuration
{
using System;
+ using LearningHub.Nhs.Shared.Configuration;
using LearningHub.Nhs.WebUI.Models.Contribute;
///
@@ -249,7 +250,7 @@ public Settings()
///
/// Gets or sets the FindwiseSettings.
///
- public FindwiseSettings FindwiseSettings { get; set; } = new FindwiseSettings();
+ public FindwiseSettingsPublic FindwiseSettings { get; set; } = new FindwiseSettingsPublic();
///
/// Gets or sets the MediaKindSettings.
diff --git a/LearningHub.Nhs.WebUI/Controllers/Api/ProviderController.cs b/LearningHub.Nhs.WebUI/Controllers/Api/ProviderController.cs
index ae3ccb97d..a154d4da8 100644
--- a/LearningHub.Nhs.WebUI/Controllers/Api/ProviderController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/Api/ProviderController.cs
@@ -1,6 +1,7 @@
namespace LearningHub.Nhs.WebUI.Controllers.Api
{
using System.Threading.Tasks;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
diff --git a/LearningHub.Nhs.WebUI/Controllers/Api/SearchController.cs b/LearningHub.Nhs.WebUI/Controllers/Api/SearchController.cs
index 1c7eef217..a83e2234d 100644
--- a/LearningHub.Nhs.WebUI/Controllers/Api/SearchController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/Api/SearchController.cs
@@ -5,6 +5,11 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Search;
+ using LearningHub.Nhs.Shared.Helpers;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
+ using LearningHub.Nhs.Shared.Models.Search;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Helpers;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models;
diff --git a/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs b/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs
index 12d9973ac..ddb34dc6f 100644
--- a/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs
@@ -13,11 +13,13 @@
using LearningHub.Nhs.Models.Hierarchy;
using LearningHub.Nhs.Models.Search;
using LearningHub.Nhs.Models.User;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
+ using LearningHub.Nhs.Shared.Models;
+ using LearningHub.Nhs.Shared.Models.Search;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Filters;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models.Catalogue;
- using LearningHub.Nhs.WebUI.Models.Search;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
@@ -270,7 +272,7 @@ public async Task IndexAsync(string reference, string tab, int? n
{
if (viewModel.SearchResults == null)
{
- viewModel.SearchResults = new Models.Search.SearchResultViewModel();
+ viewModel.SearchResults = new LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel();
}
if (search.Term != null)
diff --git a/LearningHub.Nhs.WebUI/Controllers/LogoutController.cs b/LearningHub.Nhs.WebUI/Controllers/LogoutController.cs
index 99244e3ed..9d79d1f24 100644
--- a/LearningHub.Nhs.WebUI/Controllers/LogoutController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/LogoutController.cs
@@ -6,14 +6,11 @@
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading.Tasks;
-
using IdentityModel;
using IdentityModel.Client;
-
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Handlers;
- using LearningHub.Nhs.WebUI.Interfaces;
-
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
diff --git a/LearningHub.Nhs.WebUI/Controllers/SearchController.cs b/LearningHub.Nhs.WebUI/Controllers/SearchController.cs
index ff1afba0d..9d92a4277 100644
--- a/LearningHub.Nhs.WebUI/Controllers/SearchController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/SearchController.cs
@@ -7,9 +7,11 @@ namespace LearningHub.Nhs.WebUI.Controllers
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Search;
using LearningHub.Nhs.Models.Search.SearchClick;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
+ using LearningHub.Nhs.Shared.Models.Search;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Filters;
using LearningHub.Nhs.WebUI.Interfaces;
- using LearningHub.Nhs.WebUI.Models.Search;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
diff --git a/LearningHub.Nhs.WebUI/Helpers/LearningHubApiFacade.cs b/LearningHub.Nhs.WebUI/Helpers/LearningHubApiFacade.cs
index adeb102a7..204333bba 100644
--- a/LearningHub.Nhs.WebUI/Helpers/LearningHubApiFacade.cs
+++ b/LearningHub.Nhs.WebUI/Helpers/LearningHubApiFacade.cs
@@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Common;
- using LearningHub.Nhs.WebUI.Interfaces;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using Newtonsoft.Json;
///
diff --git a/LearningHub.Nhs.WebUI/Interfaces/ILearningHubHttpClient.cs b/LearningHub.Nhs.WebUI/Interfaces/ILearningHubHttpClient.cs
deleted file mode 100644
index d39113d99..000000000
--- a/LearningHub.Nhs.WebUI/Interfaces/ILearningHubHttpClient.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace LearningHub.Nhs.WebUI.Interfaces
-{
- using System.Net.Http;
- using System.Threading.Tasks;
-
- ///
- /// The LearningHubHttpClient interface.
- ///
- public interface ILearningHubHttpClient
- {
- ///
- /// The get client.
- ///
- /// The .
- Task GetClientAsync();
- }
-}
diff --git a/LearningHub.Nhs.WebUI/Interfaces/IUserApiHttpClient.cs b/LearningHub.Nhs.WebUI/Interfaces/IUserApiHttpClient.cs
deleted file mode 100644
index fb65ab6ee..000000000
--- a/LearningHub.Nhs.WebUI/Interfaces/IUserApiHttpClient.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace LearningHub.Nhs.WebUI.Interfaces
-{
- using System.Net.Http;
- using System.Threading.Tasks;
-
- ///
- /// The User Api HttpClient interface.
- ///
- public interface IUserApiHttpClient
- {
- ///
- /// The get client.
- ///
- /// The .
- Task GetClientAsync();
- }
-}
diff --git a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
index dc2cf661d..474ac1ac4 100644
--- a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
+++ b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
@@ -167,6 +167,10 @@
+
+
+
+
diff --git a/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs b/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs
index b9fd30dca..c5835ab94 100644
--- a/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs
+++ b/LearningHub.Nhs.WebUI/Models/Catalogue/CatalogueIndexViewModel.cs
@@ -4,7 +4,7 @@
using LearningHub.Nhs.Models.Catalogue;
using LearningHub.Nhs.Models.Hierarchy;
using LearningHub.Nhs.Models.User;
- using LearningHub.Nhs.WebUI.Models.Search;
+ using LearningHub.Nhs.Shared.Models.Search;
///
/// Defines the .
diff --git a/LearningHub.Nhs.WebUI/Services/ActivityService.cs b/LearningHub.Nhs.WebUI/Services/ActivityService.cs
index a494bea91..f3e24b67e 100644
--- a/LearningHub.Nhs.WebUI/Services/ActivityService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ActivityService.cs
@@ -8,6 +8,8 @@
using LearningHub.Nhs.Models.Resource;
using LearningHub.Nhs.Models.Resource.Activity;
using LearningHub.Nhs.Models.Validation;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/BaseHttpClient.cs b/LearningHub.Nhs.WebUI/Services/BaseHttpClient.cs
index a8ebda5ef..cb2900fc2 100644
--- a/LearningHub.Nhs.WebUI/Services/BaseHttpClient.cs
+++ b/LearningHub.Nhs.WebUI/Services/BaseHttpClient.cs
@@ -10,6 +10,7 @@
using IdentityModel.Client;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.Extensions;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Extensions;
using Microsoft.AspNetCore.Authentication;
@@ -20,7 +21,7 @@
///
/// The abstract api http client.
///
- public abstract class BaseHttpClient
+ public abstract class BaseHttpClient : IAPIHttpClient
{
private static readonly ConcurrentDictionary DictionaryLocks = new ConcurrentDictionary();
diff --git a/LearningHub.Nhs.WebUI/Services/BoomarkService.cs b/LearningHub.Nhs.WebUI/Services/BoomarkService.cs
index 5a26148cc..9428b3b95 100644
--- a/LearningHub.Nhs.WebUI/Services/BoomarkService.cs
+++ b/LearningHub.Nhs.WebUI/Services/BoomarkService.cs
@@ -6,6 +6,8 @@
using System.Text;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Bookmark;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/CardService.cs b/LearningHub.Nhs.WebUI/Services/CardService.cs
index d0795c0ad..e87c2a2ff 100644
--- a/LearningHub.Nhs.WebUI/Services/CardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/CardService.cs
@@ -6,6 +6,8 @@ namespace LearningHub.Nhs.WebUI.Services
using System.Text;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Resource.ResourceDisplay;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/CatalogueService.cs b/LearningHub.Nhs.WebUI/Services/CatalogueService.cs
index a8a6d3055..b711e7c2b 100644
--- a/LearningHub.Nhs.WebUI/Services/CatalogueService.cs
+++ b/LearningHub.Nhs.WebUI/Services/CatalogueService.cs
@@ -10,6 +10,8 @@
using LearningHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.User;
using LearningHub.Nhs.Models.Validation;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/ContentService.cs b/LearningHub.Nhs.WebUI/Services/ContentService.cs
index 92fe7a7dd..281564950 100644
--- a/LearningHub.Nhs.WebUI/Services/ContentService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ContentService.cs
@@ -1,8 +1,10 @@
-namespace LearningHub.Nhs.WebUI.Services
+namespace LearningHub.Nhs.Shared.Services
{
using System;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Content;
+ using LearningHub.Nhs.Shared.Interfaces;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/ContributeService.cs b/LearningHub.Nhs.WebUI/Services/ContributeService.cs
index a61487e4e..dd69c37b4 100644
--- a/LearningHub.Nhs.WebUI/Services/ContributeService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ContributeService.cs
@@ -13,6 +13,8 @@
using LearningHub.Nhs.Models.Resource;
using LearningHub.Nhs.Models.Resource.Contribute;
using LearningHub.Nhs.Models.Validation;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models.Contribute;
using Microsoft.AspNetCore.Http;
diff --git a/LearningHub.Nhs.WebUI/Services/CountryService.cs b/LearningHub.Nhs.WebUI/Services/CountryService.cs
index 2c0c7e120..b16737317 100644
--- a/LearningHub.Nhs.WebUI/Services/CountryService.cs
+++ b/LearningHub.Nhs.WebUI/Services/CountryService.cs
@@ -5,6 +5,8 @@
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
using elfhHub.Nhs.Models.Entities;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/DashboardService.cs b/LearningHub.Nhs.WebUI/Services/DashboardService.cs
index 55f5153bf..226e0392a 100644
--- a/LearningHub.Nhs.WebUI/Services/DashboardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/DashboardService.cs
@@ -10,6 +10,8 @@
using LearningHub.Nhs.Models.Entities.Analytics;
using LearningHub.Nhs.Models.Entities.Reporting;
using LearningHub.Nhs.Services.Interface;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models;
using Microsoft.Extensions.Logging;
diff --git a/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs b/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs
index da62c5cbd..8cd0c6dd1 100644
--- a/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs
+++ b/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs
@@ -2,6 +2,8 @@
{
using System;
using System.Threading.Tasks;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
diff --git a/LearningHub.Nhs.WebUI/Services/GradeService.cs b/LearningHub.Nhs.WebUI/Services/GradeService.cs
index fb0a42074..3baabdd83 100644
--- a/LearningHub.Nhs.WebUI/Services/GradeService.cs
+++ b/LearningHub.Nhs.WebUI/Services/GradeService.cs
@@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/HierarchyService.cs b/LearningHub.Nhs.WebUI/Services/HierarchyService.cs
index 4bd8f7734..6df3f2090 100644
--- a/LearningHub.Nhs.WebUI/Services/HierarchyService.cs
+++ b/LearningHub.Nhs.WebUI/Services/HierarchyService.cs
@@ -4,6 +4,8 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.Hierarchy;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Helpers;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
diff --git a/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs b/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs
index d578d9523..6105f0512 100644
--- a/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs
+++ b/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs
@@ -3,6 +3,8 @@
using System;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Maintenance;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/JobRoleService.cs b/LearningHub.Nhs.WebUI/Services/JobRoleService.cs
index bbf9f4402..97433bab8 100644
--- a/LearningHub.Nhs.WebUI/Services/JobRoleService.cs
+++ b/LearningHub.Nhs.WebUI/Services/JobRoleService.cs
@@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Helpers;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models.Account;
diff --git a/LearningHub.Nhs.WebUI/Services/LearningHubHttpClient.cs b/LearningHub.Nhs.WebUI/Services/LearningHubHttpClient.cs
index 460ddabc3..9af95a1e6 100644
--- a/LearningHub.Nhs.WebUI/Services/LearningHubHttpClient.cs
+++ b/LearningHub.Nhs.WebUI/Services/LearningHubHttpClient.cs
@@ -2,6 +2,7 @@
{
using System.Net.Http;
using LearningHub.Nhs.Caching;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.AspNetCore.Http;
diff --git a/LearningHub.Nhs.WebUI/Services/LocationService.cs b/LearningHub.Nhs.WebUI/Services/LocationService.cs
index 2ba678ab0..29d9be912 100644
--- a/LearningHub.Nhs.WebUI/Services/LocationService.cs
+++ b/LearningHub.Nhs.WebUI/Services/LocationService.cs
@@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs b/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs
index 306d69304..433f5a7ba 100644
--- a/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs
@@ -9,6 +9,8 @@
using elfhHub.Nhs.Models.Entities;
using elfhHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/MyLearningService.cs b/LearningHub.Nhs.WebUI/Services/MyLearningService.cs
index c6f9f2ffb..4d51dcbe5 100644
--- a/LearningHub.Nhs.WebUI/Services/MyLearningService.cs
+++ b/LearningHub.Nhs.WebUI/Services/MyLearningService.cs
@@ -7,6 +7,8 @@
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.MyLearning;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/NotificationService.cs b/LearningHub.Nhs.WebUI/Services/NotificationService.cs
index d41ef30d6..4ce1afb09 100644
--- a/LearningHub.Nhs.WebUI/Services/NotificationService.cs
+++ b/LearningHub.Nhs.WebUI/Services/NotificationService.cs
@@ -9,6 +9,8 @@
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Notification;
using LearningHub.Nhs.Models.Paging;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs b/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs
index 7a7a33616..59230f71b 100644
--- a/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs
+++ b/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs
@@ -12,6 +12,8 @@
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;
using LearningHub.Nhs.Models.Resource.Files;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.AspNetCore.StaticFiles;
diff --git a/LearningHub.Nhs.WebUI/Services/RatingService.cs b/LearningHub.Nhs.WebUI/Services/RatingService.cs
index f08361096..724256728 100644
--- a/LearningHub.Nhs.WebUI/Services/RatingService.cs
+++ b/LearningHub.Nhs.WebUI/Services/RatingService.cs
@@ -6,6 +6,8 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Common;
using LearningHub.Nhs.Models.Validation;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/RegionService.cs b/LearningHub.Nhs.WebUI/Services/RegionService.cs
index 6a48fcf5d..f0211252f 100644
--- a/LearningHub.Nhs.WebUI/Services/RegionService.cs
+++ b/LearningHub.Nhs.WebUI/Services/RegionService.cs
@@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/ResourceService.cs b/LearningHub.Nhs.WebUI/Services/ResourceService.cs
index 02a233ea0..6577ba801 100644
--- a/LearningHub.Nhs.WebUI/Services/ResourceService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ResourceService.cs
@@ -15,6 +15,8 @@ namespace LearningHub.Nhs.WebUI.Services
using LearningHub.Nhs.Models.Resource.Contribute;
using LearningHub.Nhs.Models.Resource.ResourceDisplay;
using LearningHub.Nhs.Models.Validation;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models;
using Microsoft.Extensions.Logging;
diff --git a/LearningHub.Nhs.WebUI/Services/RoadMapService.cs b/LearningHub.Nhs.WebUI/Services/RoadMapService.cs
index 210a06096..33210c4fb 100644
--- a/LearningHub.Nhs.WebUI/Services/RoadMapService.cs
+++ b/LearningHub.Nhs.WebUI/Services/RoadMapService.cs
@@ -3,6 +3,8 @@
using System;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.RoadMap;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/RoleService.cs b/LearningHub.Nhs.WebUI/Services/RoleService.cs
index cfc3c8ff8..32b0af0d8 100644
--- a/LearningHub.Nhs.WebUI/Services/RoleService.cs
+++ b/LearningHub.Nhs.WebUI/Services/RoleService.cs
@@ -6,6 +6,8 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.User;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
diff --git a/LearningHub.Nhs.WebUI/Services/SpecialtyService.cs b/LearningHub.Nhs.WebUI/Services/SpecialtyService.cs
index adc3f41bb..46410724c 100644
--- a/LearningHub.Nhs.WebUI/Services/SpecialtyService.cs
+++ b/LearningHub.Nhs.WebUI/Services/SpecialtyService.cs
@@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using elfhHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/TermsAndConditionsService.cs b/LearningHub.Nhs.WebUI/Services/TermsAndConditionsService.cs
index db00925e6..24c6ddd65 100644
--- a/LearningHub.Nhs.WebUI/Services/TermsAndConditionsService.cs
+++ b/LearningHub.Nhs.WebUI/Services/TermsAndConditionsService.cs
@@ -7,6 +7,8 @@
using elfhHub.Nhs.Models.Common;
using elfhHub.Nhs.Models.Entities;
using LearningHub.Nhs.Models.Common;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
diff --git a/LearningHub.Nhs.WebUI/Services/UserApiHttpClient.cs b/LearningHub.Nhs.WebUI/Services/UserApiHttpClient.cs
index 399ad34cc..f16d5a311 100644
--- a/LearningHub.Nhs.WebUI/Services/UserApiHttpClient.cs
+++ b/LearningHub.Nhs.WebUI/Services/UserApiHttpClient.cs
@@ -2,6 +2,7 @@
{
using System.Net.Http;
using LearningHub.Nhs.Caching;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.AspNetCore.Http;
diff --git a/LearningHub.Nhs.WebUI/Services/UserGroupService.cs b/LearningHub.Nhs.WebUI/Services/UserGroupService.cs
index c9b196bfc..bfc465966 100644
--- a/LearningHub.Nhs.WebUI/Services/UserGroupService.cs
+++ b/LearningHub.Nhs.WebUI/Services/UserGroupService.cs
@@ -8,6 +8,8 @@
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Extensions;
using LearningHub.Nhs.Models.User;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
diff --git a/LearningHub.Nhs.WebUI/Services/UserService.cs b/LearningHub.Nhs.WebUI/Services/UserService.cs
index a0ba11d9a..d9addf3fa 100644
--- a/LearningHub.Nhs.WebUI/Services/UserService.cs
+++ b/LearningHub.Nhs.WebUI/Services/UserService.cs
@@ -19,6 +19,8 @@
using LearningHub.Nhs.Models.Resource;
using LearningHub.Nhs.Models.User;
using LearningHub.Nhs.Models.Validation;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Helpers;
using LearningHub.Nhs.WebUI.Interfaces;
diff --git a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs
index fdab0fc8a..ad98a2b59 100644
--- a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs
+++ b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs
@@ -5,6 +5,9 @@
using LearningHub.Nhs.Models.OpenAthens;
using LearningHub.Nhs.Services;
using LearningHub.Nhs.Services.Interface;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.Shared.Interfaces.Services;
+ using LearningHub.Nhs.Shared.Services;
using LearningHub.Nhs.WebUI.Filters;
using LearningHub.Nhs.WebUI.Helpers;
using LearningHub.Nhs.WebUI.Interfaces;
diff --git a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationGradePaging.cshtml b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationGradePaging.cshtml
index 03d66e1a2..542fcc8de 100644
--- a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationGradePaging.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationGradePaging.cshtml
@@ -1,7 +1,7 @@
@model LearningHub.Nhs.WebUI.Models.Account.AccountCreationPagingModel;
@using System.Web;
@using LearningHub.Nhs.WebUI.Models.Account
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@{
var pagingModel = Model;
diff --git a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationJobRolePaging.cshtml b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationJobRolePaging.cshtml
index 2b469af6b..cafd17275 100644
--- a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationJobRolePaging.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationJobRolePaging.cshtml
@@ -1,7 +1,7 @@
@model LearningHub.Nhs.WebUI.Models.Account.AccountCreationPagingModel;
@using System.Web;
@using LearningHub.Nhs.WebUI.Models.Account
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@{
var pagingModel = Model;
diff --git a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationRegionPaging.cshtml b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationRegionPaging.cshtml
index f3f1c7506..b834f1ec9 100644
--- a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationRegionPaging.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationRegionPaging.cshtml
@@ -1,7 +1,7 @@
@model LearningHub.Nhs.WebUI.Models.Account.AccountCreationPagingModel;
@using System.Web;
@using LearningHub.Nhs.WebUI.Models.Account
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@{
var pagingModel = Model;
diff --git a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationSpecialtyPaging.cshtml b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationSpecialtyPaging.cshtml
index ddeb89483..86114cc6d 100644
--- a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationSpecialtyPaging.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationSpecialtyPaging.cshtml
@@ -1,7 +1,7 @@
@model LearningHub.Nhs.WebUI.Models.Account.AccountCreationPagingModel;
@using System.Web;
@using LearningHub.Nhs.WebUI.Models.Account
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@{
var pagingModel = Model;
diff --git a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationWorkPlacePaging.cshtml b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationWorkPlacePaging.cshtml
index 11080dada..052f4189b 100644
--- a/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationWorkPlacePaging.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Account/_AccountCreationWorkPlacePaging.cshtml
@@ -1,7 +1,7 @@
@model LearningHub.Nhs.WebUI.Models.Account.AccountCreationPagingModel;
@using System.Web;
@using LearningHub.Nhs.WebUI.Models.Account
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@{
var pagingModel = Model;
diff --git a/LearningHub.Nhs.WebUI/Views/Bookmark/_BookmarkItem.cshtml b/LearningHub.Nhs.WebUI/Views/Bookmark/_BookmarkItem.cshtml
index 19d19e07a..d8fdfc493 100644
--- a/LearningHub.Nhs.WebUI/Views/Bookmark/_BookmarkItem.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Bookmark/_BookmarkItem.cshtml
@@ -1,4 +1,5 @@
@using LearningHub.Nhs.Models.Enums
+@using LearningHub.Nhs.Shared.Helpers
@model LearningHub.Nhs.WebUI.Models.Bookmark.BookmarkItemViewModel
@{
diff --git a/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml b/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml
index c3dbb7e45..e43637add 100644
--- a/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml
@@ -1,3 +1,4 @@
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.Models.Hierarchy
@using LearningHub.Nhs.WebUI.Models;
diff --git a/LearningHub.Nhs.WebUI/Views/Catalogue/_ContentStructure.cshtml b/LearningHub.Nhs.WebUI/Views/Catalogue/_ContentStructure.cshtml
index a39cfebcd..eb88ea682 100644
--- a/LearningHub.Nhs.WebUI/Views/Catalogue/_ContentStructure.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Catalogue/_ContentStructure.cshtml
@@ -1,5 +1,6 @@
@using LearningHub.Nhs.Models.Enums;
@using LearningHub.Nhs.Models.Hierarchy;
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Models.Catalogue;
@model CatalogueIndexViewModel;
diff --git a/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchPagination.cshtml b/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchPagination.cshtml
index dbccf1ee7..d417e4f1a 100644
--- a/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchPagination.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchPagination.cshtml
@@ -1,5 +1,5 @@
@using Microsoft.AspNetCore.WebUtilities
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
var pagingModel = Model.ResourceResultPaging;
diff --git a/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchWithinCatalogue.cshtml b/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchWithinCatalogue.cshtml
index eba2471d7..da9e95c6a 100644
--- a/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchWithinCatalogue.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Catalogue/_SearchWithinCatalogue.cshtml
@@ -1,4 +1,4 @@
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
diff --git a/LearningHub.Nhs.WebUI/Views/Home/_CatalogueCard.cshtml b/LearningHub.Nhs.WebUI/Views/Home/_CatalogueCard.cshtml
index 341556517..90b803671 100644
--- a/LearningHub.Nhs.WebUI/Views/Home/_CatalogueCard.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Home/_CatalogueCard.cshtml
@@ -1,4 +1,5 @@
@using LearningHub.Nhs.Models.Dashboard
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.WebUI.Helpers
@model DashboardCatalogueViewModel
diff --git a/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml b/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml
index 68ad72564..f739f661d 100644
--- a/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml
@@ -1,4 +1,5 @@
@using LearningHub.Nhs.Models.Dashboard
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.WebUI.Helpers
@model MoodleCourseResponseViewModel
diff --git a/LearningHub.Nhs.WebUI/Views/Home/_ResourceCard.cshtml b/LearningHub.Nhs.WebUI/Views/Home/_ResourceCard.cshtml
index 7e70482ab..d9e826e98 100644
--- a/LearningHub.Nhs.WebUI/Views/Home/_ResourceCard.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Home/_ResourceCard.cshtml
@@ -1,6 +1,7 @@
@using LearningHub.Nhs.Models.Dashboard
@using LearningHub.Nhs.Models.Provider
@using LearningHub.Nhs.Models.Enums
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.WebUI.Models
@using System.Linq
diff --git a/LearningHub.Nhs.WebUI/Views/MyLearning/LearningCertificate.cshtml b/LearningHub.Nhs.WebUI/Views/MyLearning/LearningCertificate.cshtml
index 120832cf7..83ef4c1e4 100644
--- a/LearningHub.Nhs.WebUI/Views/MyLearning/LearningCertificate.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/MyLearning/LearningCertificate.cshtml
@@ -1,6 +1,7 @@
@using LearningHub.Nhs.Models.Enums
@using LearningHub.Nhs.Models.Hierarchy
@using LearningHub.Nhs.Models.Resource.ResourceDisplay
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Configuration;
@using LearningHub.Nhs.WebUI.Models
@using LearningHub.Nhs.WebUI.Models.Learning
diff --git a/LearningHub.Nhs.WebUI/Views/MyLearning/_ActivityTablePaging.cshtml b/LearningHub.Nhs.WebUI/Views/MyLearning/_ActivityTablePaging.cshtml
index 2a67789be..6c724d5d6 100644
--- a/LearningHub.Nhs.WebUI/Views/MyLearning/_ActivityTablePaging.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/MyLearning/_ActivityTablePaging.cshtml
@@ -1,6 +1,6 @@
@using System.Web;
@using LearningHub.Nhs.WebUI.Models.Learning
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@model MyLearningViewModel;
diff --git a/LearningHub.Nhs.WebUI/Views/Resource/Resource.cshtml b/LearningHub.Nhs.WebUI/Views/Resource/Resource.cshtml
index 91d3e63eb..987df7244 100644
--- a/LearningHub.Nhs.WebUI/Views/Resource/Resource.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Resource/Resource.cshtml
@@ -1,5 +1,6 @@
@model ResourceIndexViewModel
@using LearningHub.Nhs.Models.Enums
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.WebUI.Models
@using LearningHub.Nhs.WebUI.Models.Resource
diff --git a/LearningHub.Nhs.WebUI/Views/Resource/_ResourceInformation.cshtml b/LearningHub.Nhs.WebUI/Views/Resource/_ResourceInformation.cshtml
index 98342b4db..478c1be2e 100644
--- a/LearningHub.Nhs.WebUI/Views/Resource/_ResourceInformation.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Resource/_ResourceInformation.cshtml
@@ -1,5 +1,6 @@
@model ResourceIndexViewModel
@using LearningHub.Nhs.Models.Enums
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Helpers
@using LearningHub.Nhs.WebUI.Models
@using LearningHub.Nhs.WebUI.Models.Resource
diff --git a/LearningHub.Nhs.WebUI/Views/Resource/_ResourceItem.cshtml b/LearningHub.Nhs.WebUI/Views/Resource/_ResourceItem.cshtml
index 0913435ff..9b568b55e 100644
--- a/LearningHub.Nhs.WebUI/Views/Resource/_ResourceItem.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Resource/_ResourceItem.cshtml
@@ -1,5 +1,6 @@
@model ResourceIndexViewModel
@using LearningHub.Nhs.Models.Enums
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Helpers
@using LearningHub.Nhs.WebUI.Models
@using LearningHub.Nhs.WebUI.Models.Resource
diff --git a/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml b/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml
index 4b8e0e6e3..f1ff3ea06 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/Index.cshtml
@@ -1,4 +1,4 @@
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
ViewData["Title"] = "Search";
diff --git a/LearningHub.Nhs.WebUI/Views/Search/_CataloguePagination.cshtml b/LearningHub.Nhs.WebUI/Views/Search/_CataloguePagination.cshtml
index 04cd0a9c0..d06f7ff5e 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/_CataloguePagination.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/_CataloguePagination.cshtml
@@ -1,5 +1,5 @@
@using Microsoft.AspNetCore.WebUtilities
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
var pagingModel = Model.CatalogueResultPaging;
diff --git a/LearningHub.Nhs.WebUI/Views/Search/_CatalogueSearchResult.cshtml b/LearningHub.Nhs.WebUI/Views/Search/_CatalogueSearchResult.cshtml
index 55b297410..48888b2f3 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/_CatalogueSearchResult.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/_CatalogueSearchResult.cshtml
@@ -2,7 +2,7 @@
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.Models.Search.SearchClick;
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
var catalogueResult = Model.CatalogueSearchResult;
diff --git a/LearningHub.Nhs.WebUI/Views/Search/_ResourceFilter.cshtml b/LearningHub.Nhs.WebUI/Views/Search/_ResourceFilter.cshtml
index 429eae962..a0867096a 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/_ResourceFilter.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/_ResourceFilter.cshtml
@@ -1,5 +1,5 @@
@using Microsoft.AspNetCore.WebUtilities
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
var resourceResult = Model.ResourceSearchResult;
diff --git a/LearningHub.Nhs.WebUI/Views/Search/_ResourcePagination.cshtml b/LearningHub.Nhs.WebUI/Views/Search/_ResourcePagination.cshtml
index b9b511dd5..563c052f9 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/_ResourcePagination.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/_ResourcePagination.cshtml
@@ -1,5 +1,5 @@
@using Microsoft.AspNetCore.WebUtilities
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
var pagingModel = Model.ResourceResultPaging;
diff --git a/LearningHub.Nhs.WebUI/Views/Search/_ResourceSearchResult.cshtml b/LearningHub.Nhs.WebUI/Views/Search/_ResourceSearchResult.cshtml
index 647583787..94d5fd904 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/_ResourceSearchResult.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/_ResourceSearchResult.cshtml
@@ -1,13 +1,14 @@
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration;
@using System.Linq;
@using System.Web;
+@using LearningHub.Nhs.Shared.Helpers
@using LearningHub.Nhs.WebUI.Helpers;
@using LearningHub.Nhs.Models.Search;
@using LearningHub.Nhs.Models.Search.SearchFeedback;
@using LearningHub.Nhs.Models.Enums;
-@using LearningHub.Nhs.WebUI.Models.Search;
+@using LearningHub.Nhs.Shared.Models.Search;
@using LearningHub.Nhs.Models.Search.SearchClick;
@{
diff --git a/LearningHub.Nhs.WebUI/Views/Search/_SubmitFeedback.cshtml b/LearningHub.Nhs.WebUI/Views/Search/_SubmitFeedback.cshtml
index a1ab36e1a..317772449 100644
--- a/LearningHub.Nhs.WebUI/Views/Search/_SubmitFeedback.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Search/_SubmitFeedback.cshtml
@@ -1,5 +1,5 @@
@using Microsoft.AspNetCore.WebUtilities
-@model LearningHub.Nhs.WebUI.Models.Search.SearchResultViewModel
+@model LearningHub.Nhs.Shared.Models.Search.SearchResultViewModel
@{
var queryParams = QueryHelpers.ParseQuery(Context.Request.QueryString.ToString().ToLower());
diff --git a/LearningHub.Nhs.WebUI/Views/Shared/_TwitterFeeds.cshtml b/LearningHub.Nhs.WebUI/Views/Shared/_TwitterFeeds.cshtml
index 3ec036c6c..0d096a708 100644
--- a/LearningHub.Nhs.WebUI/Views/Shared/_TwitterFeeds.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Shared/_TwitterFeeds.cshtml
@@ -1,4 +1,4 @@
-@using LearningHub.Nhs.WebUI.Helpers;
+@using LearningHub.Nhs.Shared.Helpers;
@model List
From aa9a1a5cafb8d0c6b4b2f6dfa4f7186f1c74c7c4 Mon Sep 17 00:00:00 2001
From: Phil-NHS
Date: Wed, 30 Jul 2025 14:47:44 +0100
Subject: [PATCH 05/27] TD-5862 Squash following merging RC changes
---
.../Configuration/BFFPathValidationOptions.cs | 25 ++
.../Controllers/Api/BFFController.cs | 245 ++++++++++++++++++
2 files changed, 270 insertions(+)
create mode 100644 LearningHub.Nhs.WebUI/Configuration/BFFPathValidationOptions.cs
create mode 100644 LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs
diff --git a/LearningHub.Nhs.WebUI/Configuration/BFFPathValidationOptions.cs b/LearningHub.Nhs.WebUI/Configuration/BFFPathValidationOptions.cs
new file mode 100644
index 000000000..3d0d490af
--- /dev/null
+++ b/LearningHub.Nhs.WebUI/Configuration/BFFPathValidationOptions.cs
@@ -0,0 +1,25 @@
+namespace LearningHub.Nhs.WebUI.Configuration
+{
+ using System.Collections.Generic;
+
+ ///
+ /// Configuration options for validating BFF paths.
+ ///
+ public class BFFPathValidationOptions
+ {
+ ///
+ /// Gets the section name for BFF path validation options.
+ ///
+ public const string SectionName = "BFFPathValidation";
+
+ ///
+ /// Gets or sets which apis and api stems we are allowing.
+ ///
+ public List AllowedPathPrefixes { get; set; } = new List();
+
+ ///
+ /// Gets or sets fine tuning of what paths the BFF can be used to access and what not to, where we want to specifically protect against something.
+ ///
+ public List BlockedPathSegments { get; set; } = new List();
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs b/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs
new file mode 100644
index 000000000..c5f082d75
--- /dev/null
+++ b/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs
@@ -0,0 +1,245 @@
+namespace LearningHub.Nhs.WebUI.Controllers.Api
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net.Http;
+ using System.Net.Http.Headers;
+ using System.Threading.Tasks;
+ using LearningHub.Nhs.Shared.Interfaces.Http;
+ using LearningHub.Nhs.WebUI.Configuration;
+ using Microsoft.AspNetCore.Authorization;
+ using Microsoft.AspNetCore.Mvc;
+ using Microsoft.Extensions.Logging;
+ using Microsoft.Extensions.Options;
+
+ ///
+ /// This controller allows proxying of requests to different APIs using same site cookie authentication.
+ /// It uses the http clients registered in the DI container.
+ /// The BFF (Backend for Frontend) pattern is used to simplify client-side code and centralize API access, application services directly call external apis currently but they could use the bff and then introduce caching there too potentially for seperation of infastructure concerns.
+ /// Unauthorized requests will be redirected to the login page so 302s are expected when unauthorized, and redirecting for using a Blazor island component for example may not be desireable so these responses need to be handled by the caller.
+ /// This controller is designed to be used with a clientside calls i.e. Blazor utilizing the BFF pattern, which enables same site cookie authentication and avoid the necessity of storing tokens in client storage
+ /// The bff prefix is followed by the API name (e.g. "learninghub", "userapi") and the path to the specific endpoint to enable easy routing to different APIs.
+ /// See confluence for more details on the BFF pattern and how to use this controller.
+ ///
+ /// The authorize same site cookie is used for security between client and server. API calls relying on policys such as AuthorizeOrCallFromLH may not be proxied as they require the Authorization header to be present.
+ [Authorize]
+ [Route("bff/{apiName}/{**path}")]
+ [ApiController]
+ public class BFFController : BaseApiController
+ {
+ private readonly IOptions bffPathValidationOptions;
+
+ ///
+ /// The list of API clients that can be used to proxy requests.
+ ///
+ private List apiClients;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The logger instance used for logging.
+ /// The HTTP client for the Learning Hub API.
+ /// The HTTP client for the User API.
+ /// The HTTP client for the Open API.
+ /// The options for validating BFF paths.
+ public BFFController(
+ ILogger logger,
+ ILearningHubHttpClient learningHubClient,
+ IUserApiHttpClient userAPIClient,
+ IOpenApiHttpClient openAPIClient,
+ IOptions bffPathValidationOptions)
+ : base(logger)
+ {
+ // Clients the BFF is being given access to, these are the only clients that can be used to proxy requests.
+ this.apiClients = new List()
+ {
+ learningHubClient,
+ userAPIClient,
+ openAPIClient,
+ };
+
+ this.bffPathValidationOptions = bffPathValidationOptions;
+ }
+
+ ///
+ /// Takes an API name and a path, and proxies the request to the appropriate API provided that api is part of the client list and the path is allowed and not blocked.
+ ///
+ /// The name of the API to which the request should be proxied.
+ /// The path of the endpoint within the specified API.
+ /// An representing the result of the proxied request.
+ [HttpGet]
+ [HttpPost]
+ [HttpPut]
+ [HttpDelete]
+ [HttpPatch]
+ public async Task ProxyRequest(string apiName, string path)
+ {
+ string sanitizedPath = path?.Trim('/').ToLowerInvariant() ?? string.Empty;
+ string sanitizedApiName = apiName?.Trim('/').ToLowerInvariant() ?? string.Empty;
+
+ IAPIHttpClient apiClient;
+ try
+ {
+ apiClient = this.apiClients.Single(x =>
+ {
+ try
+ {
+ var uri = new Uri(x.ApiUrl);
+ return uri.Host.ToLowerInvariant() == sanitizedApiName;
+ }
+ catch
+ {
+ return false;
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ this.Logger.LogError(e, "Failed to find API client for {ApiName}", sanitizedApiName);
+ return this.BadRequest($"Unknown API alias: {sanitizedApiName}");
+ }
+
+ if (!this.IsPathAllowed(sanitizedPath))
+ {
+ return this.Forbid("This path is not allowed via BFF proxy.");
+ }
+
+ var client = await apiClient.GetClientAsync();
+ string targetUrl = $"{apiClient.ApiUrl.TrimEnd('/')}/{path}";
+
+ // Add query parameters from the original request
+ if (this.Request.QueryString.HasValue)
+ {
+ targetUrl += this.Request.QueryString.Value;
+ }
+
+ /*
+ No headers for Auth, host, connection, user agent, added becaue all security is handled by serverside httpclients via baseclient
+ BaseHttpClient should handle content-type, timezone and tokens.
+ Note: We do not forward the Authorization header as the BFF pattern uses same-site cookies for authentication.
+ This means the BFF controller is responsible for handling authentication and authorization.
+ We also do not forward the Host header as it may not match the target API's expected host.
+ Header copying would only be needed if: APIs start checking for custom client headers (X-Custom-Header, X-Correlation-Id, etc.)
+ */
+
+ // Copy body if necessary (for POST, PUT, PATCH, etc.)
+ var method = new HttpMethod(this.Request.Method);
+ var requestMessage = new HttpRequestMessage(method, targetUrl);
+
+ if (this.Request.ContentLength > 0 &&
+ !string.Equals(this.Request.Method, "GET", StringComparison.OrdinalIgnoreCase) &&
+ !string.Equals(this.Request.Method, "HEAD", StringComparison.OrdinalIgnoreCase))
+ {
+ requestMessage.Content = new StreamContent(this.Request.Body);
+ if (!string.IsNullOrEmpty(this.Request.ContentType))
+ {
+ requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue(this.Request.ContentType);
+ }
+ }
+
+ try
+ {
+ var response = await client.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead);
+
+ // Handle redirects with token preservation
+ if (response.StatusCode == System.Net.HttpStatusCode.Redirect ||
+ response.StatusCode == System.Net.HttpStatusCode.Found ||
+ response.StatusCode == System.Net.HttpStatusCode.TemporaryRedirect ||
+ response.StatusCode == System.Net.HttpStatusCode.PermanentRedirect)
+ {
+ return await this.HandleRedirect(response, apiClient);
+ }
+
+ var content = await response.Content.ReadAsStringAsync();
+ var contentType = response.Content.Headers.ContentType?.MediaType ?? "application/json";
+
+ return new ContentResult
+ {
+ Content = content,
+ ContentType = contentType,
+ StatusCode = (int)response.StatusCode,
+ };
+ }
+ catch (HttpRequestException ex)
+ {
+ this.Logger.LogError(ex, "Error proxying request to {TargetUrl}", targetUrl);
+ return this.StatusCode(500, "An error occurred while processing the request.");
+ }
+ }
+
+ /*
+ Handle redirects with token preservation
+ if we are redirected the client may not handle it as it isnt the token holder so we need to continue using the bff until we get the outcome
+ if the BFF caller is not expecting redirects but only data they should handle the 302 response and redirect themselves.
+ E.g. A compontent that uses the BFF to fetch data may not be appropriate for redirecting to a specific page so the consuming client may need to have a way of handling page redirects.
+ */
+ private async Task HandleRedirect(HttpResponseMessage response, IAPIHttpClient apiClient)
+ {
+ var location = response.Headers.Location?.ToString();
+
+ if (string.IsNullOrEmpty(location))
+ {
+ return this.StatusCode((int)response.StatusCode, "Redirect location not found");
+ }
+
+ // Check if the redirect location is relative or absolute
+ string redirectUrl;
+ if (Uri.IsWellFormedUriString(location, UriKind.Absolute))
+ {
+ redirectUrl = location;
+ }
+ else
+ {
+ // Handle relative redirects
+ var baseUri = new Uri(apiClient.ApiUrl);
+ redirectUrl = new Uri(baseUri, location).ToString();
+ }
+
+ // Create a new request for the redirect
+ var redirectRequest = new HttpRequestMessage(HttpMethod.Get, redirectUrl);
+
+ // Add authentication token to the redirect request (apiClient handles this)
+ // No additional headers needed - apiClient is already configured
+ try
+ {
+ var client = await apiClient.GetClientAsync();
+ var redirectResponse = await client.SendAsync(redirectRequest);
+ var content = await redirectResponse.Content.ReadAsStringAsync();
+
+ // Our data apis are expected to return JSON, but we can handle other content types if necessary.
+ var contentType = redirectResponse.Content.Headers.ContentType?.MediaType ?? "application/json";
+
+ return new ContentResult
+ {
+ Content = content,
+ ContentType = contentType,
+ StatusCode = (int)redirectResponse.StatusCode,
+ };
+ }
+ catch (HttpRequestException ex)
+ {
+ this.Logger.LogError(ex, "Error following redirect to {RedirectUrl}", redirectUrl);
+ return this.StatusCode(500, "An error occurred while following the redirect.");
+ }
+ }
+
+ ///
+ /// Validates the path against allowed and blocked segments.
+ ///
+ private bool IsPathAllowed(string path)
+ {
+ var normalizedPath = path?.Trim('/').ToLowerInvariant() ?? string.Empty;
+
+ // Check blacklist first
+ if (this.bffPathValidationOptions.Value.BlockedPathSegments.Any(blocked => normalizedPath.Contains(blocked.ToLowerInvariant())))
+ {
+ this.Logger.LogError(" Black listed path {path} was requested and blocked", normalizedPath);
+ return false;
+ }
+
+ // Check whitelist
+ return this.bffPathValidationOptions.Value.AllowedPathPrefixes.Any(prefix => normalizedPath.StartsWith(prefix.ToLowerInvariant()));
+ }
+ }
+}
From bcd5659d9e114ac9acffc0914a15270a87e02506 Mon Sep 17 00:00:00 2001
From: Binon
Date: Wed, 30 Jul 2025 14:53:52 +0100
Subject: [PATCH 06/27] bit of moodle refactoring and reload the moodle user
---
.../Controllers/HomeController.cs | 37 ++++++--
.../Helpers/UtilityHelper.cs | 54 +++++------
.../Interfaces/IDashboardService.cs | 10 +-
.../Interfaces/IMoodleApiService.cs | 19 ++--
.../LearningHub.Nhs.WebUI.csproj | 2 +-
.../Models/DashboardViewModel.cs | 3 +-
.../Services/DashboardService.cs | 19 +++-
.../Services/MoodleApiService.cs | 64 ++++++++++---
.../Views/Home/_CourseEnrolled.cshtml | 3 +-
.../Views/Home/_MyAccessedLearningTray.cshtml | 4 +-
.../Views/Search/_ResourceSearchResult.cshtml | 2 +-
.../Configuration/MoodleConfig.cs | 29 ++++++
.../HttpClients/IMoodleHttpClient.cs | 23 +++++
.../Services/IMoodleApiService.cs | 21 ++++
.../HttpClients/MoodleHttpClient.cs | 95 +++++++++++++++++++
.../LearningHub.Nhs.OpenApi.Services.csproj | 2 +-
.../Services/MoodleApiService.cs | 90 ++++++++++++++++++
.../Startup.cs | 2 +
.../Configuration/ConfigurationExtensions.cs | 7 ++
.../Controllers/MoodleController.cs | 47 +++++++++
.../LearningHub.Nhs.OpenApi/appsettings.json | 5 +
21 files changed, 472 insertions(+), 66 deletions(-)
create mode 100644 OpenAPI/LearningHub.Nhs.OpenApi.Models/Configuration/MoodleConfig.cs
create mode 100644 OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/HttpClients/IMoodleHttpClient.cs
create mode 100644 OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IMoodleApiService.cs
create mode 100644 OpenAPI/LearningHub.Nhs.OpenApi.Services/HttpClients/MoodleHttpClient.cs
create mode 100644 OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/MoodleApiService.cs
create mode 100644 OpenAPI/LearningHub.Nhs.OpenApi/Controllers/MoodleController.cs
diff --git a/LearningHub.Nhs.WebUI/Controllers/HomeController.cs b/LearningHub.Nhs.WebUI/Controllers/HomeController.cs
index d5f53c00d..57c170ae6 100644
--- a/LearningHub.Nhs.WebUI/Controllers/HomeController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/HomeController.cs
@@ -11,6 +11,7 @@ namespace LearningHub.Nhs.WebUI.Controllers
using LearningHub.Nhs.Models.Content;
using LearningHub.Nhs.Models.Enums.Content;
using LearningHub.Nhs.Models.Extensions;
+ using LearningHub.Nhs.Models.Moodle.API;
using LearningHub.Nhs.WebUI.Configuration;
using LearningHub.Nhs.WebUI.Filters;
using LearningHub.Nhs.WebUI.Helpers;
@@ -218,13 +219,12 @@ public async Task Index(string myLearningDashboard = "my-in-progr
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);
var userGroupsTask = this.userGroupService.UserHasCatalogueContributionPermission();
- var enrolledCoursesTask = Task.FromResult(new List());
- var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
- this.ViewBag.EnableMoodle = enableMoodle;
- this.ViewBag.ValidMoodleUser = this.CurrentMoodleUserId > 0;
+ var enrolledCoursesTask = Task.FromResult(new List());
+ (bool enableMoodle, int currentMoodleUserId) = await this.GetMoodleFeatureStateAsync();
+
if (enableMoodle && myLearningDashboard == "my-enrolled-courses")
{
- enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(this.CurrentMoodleUserId, 1);
+ enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(currentMoodleUserId, 1);
}
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask, userGroupsTask);
@@ -280,9 +280,7 @@ public async Task LoadPage(string dashBoardTray = "my-learning",
Catalogues = new Nhs.Models.Dashboard.DashboardCatalogueResponseViewModel { Type = catalogueDashBoard },
};
- var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
- this.ViewBag.EnableMoodle = enableMoodle;
- this.ViewBag.ValidMoodleUser = this.CurrentMoodleUserId > 0;
+ (bool enableMoodle, int currentMoodleUserId) = await this.GetMoodleFeatureStateAsync();
bool isAjax = this.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest";
@@ -449,5 +447,28 @@ private async Task GetLandingPageContent(bool preview = fa
return new LandingPageViewModel { PageSectionDetailViewModels = new List(), PageViewModel = new PageViewModel { PageSections = new List { } } };
}
}
+
+ ///
+ /// Asynchronously retrieves the state of the Moodle feature and the current Moodle user ID.
+ ///
+ /// The method checks if the Moodle feature is enabled and retrieves the current Moodle
+ /// user ID. If the user ID is not already set, it attempts to obtain it asynchronously from the dashboard
+ /// service.
+ /// A tuple containing a boolean indicating whether the Moodle feature is enabled and an integer representing
+ /// the current Moodle user ID.
+ private async Task<(bool enableMoodle, int currentMoodleUserId)> GetMoodleFeatureStateAsync()
+ {
+ var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
+ this.ViewBag.EnableMoodle = enableMoodle;
+ int currentMoodleUserId = this.CurrentMoodleUserId;
+
+ if (currentMoodleUserId == 0)
+ {
+ currentMoodleUserId = await this.dashboardService.GetMoodleUserIdAsync(this.CurrentUserId);
+ }
+
+ this.ViewBag.ValidMoodleUser = currentMoodleUserId > 0;
+ return (enableMoodle, currentMoodleUserId);
+ }
}
}
diff --git a/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs b/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs
index ef71191f9..c07ab98e9 100644
--- a/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs
+++ b/LearningHub.Nhs.WebUI/Helpers/UtilityHelper.cs
@@ -36,19 +36,19 @@ public static class UtilityHelper
///
/// Findwise Moodle resource type dictionary.
///
- public static readonly Dictionary FindwiseResourceMoodleTypeDict = new Dictionary()
+ public static readonly Dictionary FindwiseResourceMoodleTypeDict = new Dictionary()
{
- { "video", ResourceTypeEnumMoodle.Video },
- { "article", ResourceTypeEnumMoodle.Article },
- { "case", ResourceTypeEnumMoodle.Case },
- { "weblink", ResourceTypeEnumMoodle.WebLink },
- { "audio", ResourceTypeEnumMoodle.Audio },
- { "scorm", ResourceTypeEnumMoodle.Scorm },
- { "assessment", ResourceTypeEnumMoodle.Assessment },
- { "genericfile", ResourceTypeEnumMoodle.GenericFile },
- { "image", ResourceTypeEnumMoodle.Image },
- { "html", ResourceTypeEnumMoodle.Html },
- { "moodle", ResourceTypeEnumMoodle.Course },
+ { "video", ResourceTypeEnum.Video },
+ { "article", ResourceTypeEnum.Article },
+ { "case", ResourceTypeEnum.Case },
+ { "weblink", ResourceTypeEnum.WebLink },
+ { "audio", ResourceTypeEnum.Audio },
+ { "scorm", ResourceTypeEnum.Scorm },
+ { "assessment", ResourceTypeEnum.Assessment },
+ { "genericfile", ResourceTypeEnum.GenericFile },
+ { "image", ResourceTypeEnum.Image },
+ { "html", ResourceTypeEnum.Html },
+ { "moodle", ResourceTypeEnum.Moodle },
};
///
@@ -173,41 +173,39 @@ public static string GetPrettifiedResourceTypeName(ResourceTypeEnum resourceType
/// The resource type.
/// The media duration in milliseconds.
/// The resource type name, and duration if applicable.
- public static string GetPrettifiedResourceTypeNameMoodle(ResourceTypeEnumMoodle resourceType, int? durationInMilliseconds = 0)
+ public static string GetPrettifiedResourceTypeNameMoodle(ResourceTypeEnum resourceType, int? durationInMilliseconds = 0)
{
switch (resourceType)
{
- case ResourceTypeEnumMoodle.Assessment:
+ case ResourceTypeEnum.Assessment:
return "Assessment";
- case ResourceTypeEnumMoodle.Article:
+ case ResourceTypeEnum.Article:
return "Article";
- case ResourceTypeEnumMoodle.Audio:
+ case ResourceTypeEnum.Audio:
string durationText = GetDurationText(durationInMilliseconds ?? 0);
durationText = string.IsNullOrEmpty(durationText) ? string.Empty : " - " + durationText;
return "Audio" + durationText;
- case ResourceTypeEnumMoodle.Equipment:
+ case ResourceTypeEnum.Equipment:
return "Equipment";
- case ResourceTypeEnumMoodle.Image:
+ case ResourceTypeEnum.Image:
return "Image";
- case ResourceTypeEnumMoodle.Scorm:
+ case ResourceTypeEnum.Scorm:
return "elearning";
- case ResourceTypeEnumMoodle.Video:
+ case ResourceTypeEnum.Video:
durationText = GetDurationText(durationInMilliseconds ?? 0);
durationText = string.IsNullOrEmpty(durationText) ? string.Empty : " - " + durationText;
return "Video" + durationText;
- case ResourceTypeEnumMoodle.WebLink:
+ case ResourceTypeEnum.WebLink:
return "Web link";
- case ResourceTypeEnumMoodle.GenericFile:
+ case ResourceTypeEnum.GenericFile:
return "File";
- case ResourceTypeEnumMoodle.Embedded:
+ case ResourceTypeEnum.Embedded:
return "Embedded";
- case ResourceTypeEnumMoodle.Case:
+ case ResourceTypeEnum.Case:
return "Case";
- case ResourceTypeEnumMoodle.Html:
+ case ResourceTypeEnum.Html:
return "HTML";
- case ResourceTypeEnumMoodle.Moodle:
- return "Course";
- case ResourceTypeEnumMoodle.Course:
+ case ResourceTypeEnum.Moodle:
return "Course";
default:
return "File";
diff --git a/LearningHub.Nhs.WebUI/Interfaces/IDashboardService.cs b/LearningHub.Nhs.WebUI/Interfaces/IDashboardService.cs
index 9eb8c3266..70a39d2fb 100644
--- a/LearningHub.Nhs.WebUI/Interfaces/IDashboardService.cs
+++ b/LearningHub.Nhs.WebUI/Interfaces/IDashboardService.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Dashboard;
+ using LearningHub.Nhs.Models.Moodle.API;
using LearningHub.Nhs.WebUI.Models;
///
@@ -47,6 +48,13 @@ public interface IDashboardService
/// The current User Id type.
/// The page Number.
/// A representing the result of the asynchronous operation.
- Task> GetEnrolledCoursesFromMoodleAsync(int currentUserId, int pageNumber);
+ Task> GetEnrolledCoursesFromMoodleAsync(int currentUserId, int pageNumber);
+
+ ///
+ /// GetEnrolledCoursesFromMoodleAsync.
+ ///
+ /// The current User Id type.
+ /// A representing the result of the asynchronous operation.
+ Task GetMoodleUserIdAsync(int currentUserId);
}
}
diff --git a/LearningHub.Nhs.WebUI/Interfaces/IMoodleApiService.cs b/LearningHub.Nhs.WebUI/Interfaces/IMoodleApiService.cs
index d92c01fad..60dc18cb6 100644
--- a/LearningHub.Nhs.WebUI/Interfaces/IMoodleApiService.cs
+++ b/LearningHub.Nhs.WebUI/Interfaces/IMoodleApiService.cs
@@ -2,21 +2,28 @@
{
using System.Collections.Generic;
using System.Threading.Tasks;
- using LearningHub.Nhs.Models.Dashboard;
- using LearningHub.Nhs.WebUI.Models;
+ using LearningHub.Nhs.Models.Moodle.API;
+ using MoodleCourseCompletionModel = LearningHub.Nhs.Models.Moodle.API.MoodleCourseCompletionModel;
///
/// IMoodleApiService.
///
public interface IMoodleApiService
{
+ ///
+ /// GetMoodleUserIdByUsernameAsync.
+ ///
+ /// The current LH User Id.
+ /// A representing the result of the asynchronous operation.
+ Task GetMoodleUserIdByUsernameAsync(int currentUserId);
+
///
/// GetEnrolledCoursesAsync.
///
/// Moodle user id.
/// pageNumber.
- /// List of MoodleCourseResponseViewModel.
- Task> GetEnrolledCoursesAsync(int currentUserId, int pageNumber);
+ /// List of MoodleCourseResponseModel.
+ Task> GetEnrolledCoursesAsync(int currentUserId, int pageNumber);
///
/// GetEnrolledCoursesAsync.
@@ -24,7 +31,7 @@ public interface IMoodleApiService
/// Moodle user id.
/// Moodle course id.
/// pageNumber.
- /// List of MoodleCourseResponseViewModel.
- Task GetCourseCompletionAsync(int userId, int courseId, int pageNumber);
+ /// List of MoodleCourseResponseModel.
+ Task GetCourseCompletionAsync(int userId, int courseId, int pageNumber);
}
}
diff --git a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
index dc2cf661d..b69ead582 100644
--- a/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
+++ b/LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
@@ -113,7 +113,7 @@
-
+
diff --git a/LearningHub.Nhs.WebUI/Models/DashboardViewModel.cs b/LearningHub.Nhs.WebUI/Models/DashboardViewModel.cs
index 9ac98c7e0..d7ddeda0c 100644
--- a/LearningHub.Nhs.WebUI/Models/DashboardViewModel.cs
+++ b/LearningHub.Nhs.WebUI/Models/DashboardViewModel.cs
@@ -2,6 +2,7 @@
{
using System.Collections.Generic;
using LearningHub.Nhs.Models.Dashboard;
+ using LearningHub.Nhs.Models.Moodle.API;
///
/// Defines the .
@@ -33,6 +34,6 @@ public DashboardViewModel()
///
/// Gets or sets a list of enrolled courses to be displayed in the dashboard.
///
- public List EnrolledCourses { get; set; }
+ public List EnrolledCourses { get; set; }
}
}
diff --git a/LearningHub.Nhs.WebUI/Services/DashboardService.cs b/LearningHub.Nhs.WebUI/Services/DashboardService.cs
index 607d4f2be..d04708393 100644
--- a/LearningHub.Nhs.WebUI/Services/DashboardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/DashboardService.cs
@@ -9,6 +9,7 @@
using LearningHub.Nhs.Models.Dashboard;
using LearningHub.Nhs.Models.Entities.Analytics;
using LearningHub.Nhs.Models.Entities.Reporting;
+ using LearningHub.Nhs.Models.Moodle.API;
using LearningHub.Nhs.Services.Interface;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models;
@@ -128,14 +129,26 @@ public async Task GetResourcesAsync(string d
/// The dashboard type.
/// The page Number.
/// A representing the result of the asynchronous operation.
- public async Task> GetEnrolledCoursesFromMoodleAsync(int currentUserId, int pageNumber)
+ public async Task> GetEnrolledCoursesFromMoodleAsync(int currentUserId, int pageNumber)
{
- List viewmodel = new List { };
- MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient);
+ List viewmodel = new List { };
+ MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient, this.OpenApiHttpClient);
viewmodel = await moodleApiService.GetEnrolledCoursesAsync(currentUserId, pageNumber);
return viewmodel;
}
+ ///
+ /// GetEnrolledCoursesFromMoodleAsync.
+ ///
+ /// The current User Id type.
+ /// A representing the result of the asynchronous operation.
+ public async Task GetMoodleUserIdAsync(int currentUserId)
+ {
+ MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient, this.OpenApiHttpClient);
+ var moodleUserId = await moodleApiService.GetMoodleUserIdByUsernameAsync(currentUserId);
+ return moodleUserId;
+ }
+
///
/// Logs Dashboared viewed event.
///
diff --git a/LearningHub.Nhs.WebUI/Services/MoodleApiService.cs b/LearningHub.Nhs.WebUI/Services/MoodleApiService.cs
index 068219b42..fb69d3ee8 100644
--- a/LearningHub.Nhs.WebUI/Services/MoodleApiService.cs
+++ b/LearningHub.Nhs.WebUI/Services/MoodleApiService.cs
@@ -3,15 +3,15 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
+ using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
- using LearningHub.Nhs.Models.Entities.Reporting;
+ using LearningHub.Nhs.Models.Moodle.API;
using LearningHub.Nhs.Services.Interface;
using LearningHub.Nhs.WebUI.Interfaces;
using LearningHub.Nhs.WebUI.Models;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
+ using MoodleCourseCompletionModel = Nhs.Models.Moodle.API.MoodleCourseCompletionModel;
///
/// MoodleApiService.
@@ -19,14 +19,52 @@
public class MoodleApiService : IMoodleApiService
{
private readonly IMoodleHttpClient moodleHttpClient;
+ private readonly IOpenApiHttpClient openApiHttpClient;
///
/// Initializes a new instance of the class.
///
/// moodleHttpClient.
- public MoodleApiService(IMoodleHttpClient moodleHttpClient)
+ /// The Open Api Http Client.
+ public MoodleApiService(IMoodleHttpClient moodleHttpClient, IOpenApiHttpClient openApiHttpClient)
{
this.moodleHttpClient = moodleHttpClient;
+ this.openApiHttpClient = openApiHttpClient;
+ }
+
+ ///
+ /// GetMoodleUserIdByUsernameAsync.
+ ///
+ /// current User Id.
+ /// UserId from Moodle.
+ public async Task GetMoodleUserIdByUsernameAsync(int currentUserId)
+ {
+ int moodleUserId = 0;
+
+ try
+ {
+ var client = await this.openApiHttpClient.GetClientAsync();
+
+ var request = $"Moodle/GetMoodleUserId/{currentUserId}";
+ var response = await client.GetAsync(request).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ moodleUserId = JsonConvert.DeserializeObject(result);
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("AccessDenied");
+ }
+
+ return moodleUserId;
+ }
+ catch (Exception ex)
+ {
+ // this.Logger.LogError(string.Format("Error occurred in GetSearchResultAsync: {0}", ex.Message));
+ return moodleUserId;
+ }
}
///
@@ -35,10 +73,10 @@ public MoodleApiService(IMoodleHttpClient moodleHttpClient)
/// Moodle user id.
/// The page Number.
/// A representing the result of the asynchronous operation.
- public async Task> GetEnrolledCoursesAsync(int userId, int pageNumber)
+ public async Task> GetEnrolledCoursesAsync(int userId, int pageNumber)
{
- List viewmodel = new List { };
- MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient);
+ List viewmodel = new List { };
+ MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient, this.openApiHttpClient);
var client = await this.moodleHttpClient.GetClient();
string additionalParameters = $"userid={userId}";
@@ -57,7 +95,7 @@ public async Task> GetEnrolledCoursesAsync(i
// Check if it's a JSON object and contains "exception"
if (!(root.ValueKind == JsonValueKind.Object && root.TryGetProperty("exception", out _)))
{
- viewmodel = JsonConvert.DeserializeObject>(result);
+ viewmodel = JsonConvert.DeserializeObject>(result);
foreach (var course in viewmodel)
{
@@ -84,11 +122,11 @@ public async Task> GetEnrolledCoursesAsync(i
/// Moodle user id.
/// Moodle course id.
/// pageNumber.
- /// List of MoodleCourseResponseViewModel.
- public async Task GetCourseCompletionAsync(int userId, int courseId, int pageNumber)
+ /// List of MoodleCourseResponseModel.
+ public async Task GetCourseCompletionAsync(int userId, int courseId, int pageNumber)
{
- MoodleCourseCompletionViewModel viewmodel = new MoodleCourseCompletionViewModel { };
- MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient);
+ MoodleCourseCompletionModel viewmodel = new MoodleCourseCompletionModel { };
+ MoodleApiService moodleApiService = new MoodleApiService(this.moodleHttpClient, this.openApiHttpClient);
var client = await this.moodleHttpClient.GetClient();
string additionalParameters = $"userid={userId}&courseid={courseId}";
@@ -105,7 +143,7 @@ public async Task GetCourseCompletionAsync(int
if (string.IsNullOrEmpty(canViewReport.Exception))
{
- viewmodel = JsonConvert.DeserializeObject(result);
+ viewmodel = JsonConvert.DeserializeObject(result);
}
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
diff --git a/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml b/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml
index 68ad72564..f62eea9f2 100644
--- a/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Home/_CourseEnrolled.cshtml
@@ -1,7 +1,8 @@
@using LearningHub.Nhs.Models.Dashboard
+@using LearningHub.Nhs.Models.Moodle.API
@using LearningHub.Nhs.WebUI.Extensions
@using LearningHub.Nhs.WebUI.Helpers
-@model MoodleCourseResponseViewModel
+@model MoodleCourseResponseModel
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration;
@{
diff --git a/LearningHub.Nhs.WebUI/Views/Home/_MyAccessedLearningTray.cshtml b/LearningHub.Nhs.WebUI/Views/Home/_MyAccessedLearningTray.cshtml
index 8b8d25f8a..47cf33901 100644
--- a/LearningHub.Nhs.WebUI/Views/Home/_MyAccessedLearningTray.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Home/_MyAccessedLearningTray.cshtml
@@ -32,8 +32,8 @@
TotalCount = Model.MyLearnings.TotalCount
};
- var enableMoodle = this.ViewBag.EnableMoodle;
- var validMoodleUser = this.ViewBag.ValidMoodleUser;
+ bool enableMoodle = (bool?)ViewBag.EnableMoodle ?? false;
+ bool validMoodleUser = (bool?)ViewBag.ValidMoodleUser ?? false;
}
From a88ba065459153caf1aff8d1980bb38315839f2f Mon Sep 17 00:00:00 2001
From: Phil-NHS
Date: Thu, 14 Aug 2025 14:00:45 +0100
Subject: [PATCH 23/27] TD-5924 Tidy up
---
LearningHub.Nhs.WebUI.BlazorClient/Program.cs | 8 +++-----
.../Services/WasmCacheServiceStub.cs | 4 ++--
.../Controllers/Api/BFFController.cs | 2 --
LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs | 4 +---
.../Views/Home/LandingPage.cshtml | 14 --------------
5 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/LearningHub.Nhs.WebUI.BlazorClient/Program.cs b/LearningHub.Nhs.WebUI.BlazorClient/Program.cs
index 2bd6f6949..21f83b13d 100644
--- a/LearningHub.Nhs.WebUI.BlazorClient/Program.cs
+++ b/LearningHub.Nhs.WebUI.BlazorClient/Program.cs
@@ -1,6 +1,5 @@
-using Blazored.LocalStorage; // Still required server side even if not used so components dont fail to build
+using Blazored.LocalStorage;
using LearningHub.Nhs.WebUI.BlazorClient.DI;
-
using LearningHub.Nhs.Shared.Configuration;
using LearningHub.Nhs.Shared.Interfaces.Http;
using LearningHub.Nhs.WebUI.BlazorClient.Services;
@@ -26,7 +25,6 @@
using TELBlazor.Components.Core.Services.HelperServices;
using TELBlazor.Components.OptionalImplementations.Core.Services.HelperServices;
-
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var http = new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) };
@@ -54,7 +52,7 @@
.CreateLogger();
// Add Serilog to logging providers
-builder.Logging.AddSerilog(Log.Logger, dispose: true);//qqqq may not need dispose for client
+builder.Logging.AddSerilog(Log.Logger);
//for really bad fails
try
@@ -85,7 +83,7 @@
builder.Services.AddScoped(sp => levelSwitch);
builder.Services.AddScoped();
- // TODO builder.Services.AddScoped();
+ // TODO (QQQQ) implement post TD-5925 builder.Services.AddScoped();
await builder.Build().RunAsync();
}
diff --git a/LearningHub.Nhs.WebUI.BlazorClient/Services/WasmCacheServiceStub.cs b/LearningHub.Nhs.WebUI.BlazorClient/Services/WasmCacheServiceStub.cs
index 32f2f6257..6083581c2 100644
--- a/LearningHub.Nhs.WebUI.BlazorClient/Services/WasmCacheServiceStub.cs
+++ b/LearningHub.Nhs.WebUI.BlazorClient/Services/WasmCacheServiceStub.cs
@@ -1,4 +1,4 @@
-// TODO: using LearningHub.Nhs.Caching;
+// TODO (QQQQ) implement post TD-5925: using LearningHub.Nhs.Models;
namespace LearningHub.Nhs.WebUI.BlazorClient.Services
{
@@ -6,7 +6,7 @@ namespace LearningHub.Nhs.WebUI.BlazorClient.Services
/// We may use storage, we may just stub it and throw an error, we cant directly use redis we may access it via an api
/// The cachestub currently just returns there is nothing available so the caller then will revert to calling the api.
///
- public class WasmCacheServiceStub // TODO: ICacheService
+ public class WasmCacheServiceStub // TODO (QQQQ) implement post TD-5925 and get from NHS.Models: ICacheService
{
public Task GetAsync(string key)
{
diff --git a/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs b/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs
index ef3cf02de..c5f082d75 100644
--- a/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/Api/BFFController.cs
@@ -78,7 +78,6 @@ public async Task ProxyRequest(string apiName, string path)
string sanitizedPath = path?.Trim('/').ToLowerInvariant() ?? string.Empty;
string sanitizedApiName = apiName?.Trim('/').ToLowerInvariant() ?? string.Empty;
- // qqqq https://lh-web.dev.local/bff/lh-api.dev.local/Catalogue/GetLatestCatalogueAccessRequest/500
IAPIHttpClient apiClient;
try
{
@@ -103,7 +102,6 @@ public async Task ProxyRequest(string apiName, string path)
if (!this.IsPathAllowed(sanitizedPath))
{
- // qqqq "catalogue/getlatestcatalogueaccessrequest/500"
return this.Forbid("This path is not allowed via BFF proxy.");
}
diff --git a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs
index 15b22ac86..6ea200c45 100644
--- a/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs
+++ b/LearningHub.Nhs.WebUI/Startup/ServiceMappings.cs
@@ -88,7 +88,7 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon
// Config
services.Configure(configuration.GetSection("OpenAthensScopes"));
- services.Configure(configuration.GetSection("Settings:" + BFFPathValidationOptions.SectionName)); // qqqq
+ services.Configure(configuration.GetSection("Settings:" + BFFPathValidationOptions.SectionName));
// Blazor
services.AddRazorComponents()
@@ -143,8 +143,6 @@ public static void AddLearningHubMappings(this IServiceCollection services, ICon
services.AddScoped();
//
-
- //
// Future candidates for DI collection
services.AddBlazoredLocalStorage();
diff --git a/LearningHub.Nhs.WebUI/Views/Home/LandingPage.cshtml b/LearningHub.Nhs.WebUI/Views/Home/LandingPage.cshtml
index 8de4a105c..3fcd1639c 100644
--- a/LearningHub.Nhs.WebUI/Views/Home/LandingPage.cshtml
+++ b/LearningHub.Nhs.WebUI/Views/Home/LandingPage.cshtml
@@ -37,20 +37,6 @@
Sign up, explore and learn