diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Configuration/WebSettings.cs b/AdminUI/LearningHub.Nhs.AdminUI/Configuration/WebSettings.cs
index f8e3c1565..5c8ab554f 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Configuration/WebSettings.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Configuration/WebSettings.cs
@@ -27,6 +27,11 @@ public class WebSettings
///
public string LearningHubApiUrl { get; set; }
+ ///
+ /// Gets or sets the OpenApiUrl.
+ ///
+ public string OpenApiUrl { get; set; }
+
///
/// Gets or sets the user api url.
///
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Helpers/IOpenApiFacade.cs b/AdminUI/LearningHub.Nhs.AdminUI/Helpers/IOpenApiFacade.cs
new file mode 100644
index 000000000..2bcded72b
--- /dev/null
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Helpers/IOpenApiFacade.cs
@@ -0,0 +1,59 @@
+namespace LearningHub.Nhs.AdminUI.Helpers
+{
+ using System.Threading.Tasks;
+ using LearningHub.Nhs.Models.Common;
+
+ ///
+ /// Defines the .
+ ///
+ public interface IOpenApiFacade
+ {
+ ///
+ /// The GetAsync.
+ ///
+ /// The type.
+ /// The url.
+ /// The .
+ Task GetAsync(string url)
+ where T : class, new();
+
+ ///
+ /// The PostAsync.
+ ///
+ /// The type.
+ /// The url.
+ /// The body.
+ /// The .
+ Task PostAsync(string url, T body)
+ where T : class, new();
+
+ ///
+ /// The PostAsync.
+ ///
+ /// The type.
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ Task PostAsync(string url, TBody body)
+ where T : class, new()
+ where TBody : class, new();
+
+ ///
+ /// The PutAsync.
+ ///
+ /// The url.
+ /// The .
+ Task PutAsync(string url);
+
+ ///
+ /// The PutAsync.
+ ///
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ Task PutAsync(string url, T body)
+ where T : class, new();
+ }
+}
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Helpers/OpenApiFacade.cs b/AdminUI/LearningHub.Nhs.AdminUI/Helpers/OpenApiFacade.cs
new file mode 100644
index 000000000..6169d8e6b
--- /dev/null
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Helpers/OpenApiFacade.cs
@@ -0,0 +1,241 @@
+namespace LearningHub.Nhs.AdminUI.Helpers
+{
+ using System;
+ using System.Net.Http;
+ using System.Text;
+ using System.Threading.Tasks;
+ using LearningHub.Nhs.AdminUI.Interfaces;
+ using LearningHub.Nhs.Models.Common;
+ using Newtonsoft.Json;
+
+ ///
+ /// Defines the .
+ ///
+ public class OpenApiFacade : IOpenApiFacade
+ {
+ ///
+ /// Defines the _client.
+ ///
+ private readonly IOpenApiHttpClient client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The client.
+ public OpenApiFacade(IOpenApiHttpClient client)
+ {
+ this.client = client;
+ }
+
+ ///
+ /// The GetAsync.
+ ///
+ /// .
+ /// The url.
+ /// The .
+ public async Task GetAsync(string url)
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var vm = new T();
+
+ var response = await client.GetAsync(url).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ vm = JsonConvert.DeserializeObject(result);
+
+ return vm;
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("AccessDenied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PostAsync.
+ ///
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ public async Task PostAsync(string url, T body)
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
+ var response = await client.PostAsync(url, content).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ return;
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("AccessDenied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PostAsync.
+ ///
+ /// The return type.
+ /// The type of body parameter.
+ /// The url.
+ /// The body.
+ /// The .
+ public async Task PostAsync(string url, TBody body)
+ where TBody : class, new()
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var vm = new T();
+ var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
+ var response = await client.PostAsync(url, content).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ var apiResponse = JsonConvert.DeserializeObject(result);
+ if (apiResponse.Success)
+ {
+ return apiResponse;
+ }
+ else
+ {
+ string details = string.Empty;
+ if (apiResponse.ValidationResult != null)
+ {
+ if (apiResponse.ValidationResult.Details != null)
+ {
+ details = $"::ValidationResult: {string.Join(",", apiResponse.ValidationResult.Details)}";
+ }
+ }
+
+ throw new Exception($"PostAsync ApiResponse returned False: {details}");
+ }
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("Access Denied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PutAsync.
+ ///
+ /// The url.
+ /// The .
+ public async Task PutAsync(string url)
+ {
+ var client = await this.client.GetClientAsync();
+
+ var response = await client.PutAsync(url, null).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ var apiResponse = JsonConvert.DeserializeObject(result);
+ if (apiResponse.Success)
+ {
+ return apiResponse;
+ }
+ else
+ {
+ string details = string.Empty;
+ if (apiResponse.ValidationResult != null)
+ {
+ if (apiResponse.ValidationResult.Details != null)
+ {
+ details = $"::ValidationResult: {string.Join(",", apiResponse.ValidationResult.Details)}";
+ }
+ }
+
+ throw new Exception($"PutAsync ApiResponse returned False: {details}");
+ }
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("Access Denied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PutAsync.
+ ///
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ public async Task PutAsync(string url, T body)
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
+ var response = await client.PutAsync(url, content).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ var apiResponse = JsonConvert.DeserializeObject(result);
+ if (apiResponse.Success)
+ {
+ return apiResponse;
+ }
+ else
+ {
+ string details = string.Empty;
+ if (apiResponse.ValidationResult != null)
+ {
+ if (apiResponse.ValidationResult.Details != null)
+ {
+ details = $"::ValidationResult: {string.Join(",", apiResponse.ValidationResult.Details)}";
+ }
+ }
+
+ throw new Exception($"PutAsync ApiResponse returned False: {details}");
+ }
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("Access Denied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+ }
+}
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IOpenApiHttpClient.cs b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IOpenApiHttpClient.cs
new file mode 100644
index 000000000..34c488767
--- /dev/null
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Interfaces/IOpenApiHttpClient.cs
@@ -0,0 +1,17 @@
+namespace LearningHub.Nhs.AdminUI.Interfaces
+{
+ using System.Net.Http;
+ using System.Threading.Tasks;
+
+ ///
+ /// The OpenApiHttpClient interface.
+ ///
+ public interface IOpenApiHttpClient
+ {
+ ///
+ /// The get client.
+ ///
+ /// The .
+ Task GetClientAsync();
+ }
+}
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs b/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs
index 81867365f..1039a3673 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs
@@ -86,6 +86,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur
services.AddSingleton(configuration);
services.AddScoped();
+ services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
@@ -132,11 +133,19 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur
ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
});
+ services.AddHttpClient()
+ .ConfigurePrimaryHttpMessageHandler(
+ () => new HttpClientHandler
+ {
+ ServerCertificateCustomValidationCallback =
+ HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
+ });
}
else
{
services.AddHttpClient();
services.AddHttpClient();
+ services.AddHttpClient();
}
services.AddTransient();
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/BaseService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/BaseService.cs
index ab2a377e8..c164b5691 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/BaseService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/BaseService.cs
@@ -12,6 +12,11 @@ public class BaseService
///
private ILearningHubHttpClient learningHubHttpClient;
+ ///
+ /// Defines the openApiHttpClient.
+ ///
+ private IOpenApiHttpClient openApiHttpClient;
+
///
/// Initializes a new instance of the class.
///
@@ -21,9 +26,25 @@ protected BaseService(ILearningHubHttpClient learningHubHttpClient)
this.learningHubHttpClient = learningHubHttpClient;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The learningHubHttpClient.
+ /// The openApiHttpClient.
+ protected BaseService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient)
+ {
+ this.learningHubHttpClient = learningHubHttpClient;
+ this.openApiHttpClient = openApiHttpClient;
+ }
+
///
/// Gets the LearningHubHttpClient.
///
protected ILearningHubHttpClient LearningHubHttpClient => this.learningHubHttpClient;
+
+ ///
+ /// Gets the OpenApiHttpClient.
+ ///
+ protected IOpenApiHttpClient OpenApiHttpClient => this.openApiHttpClient;
}
}
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs
index 1fa44df2b..2ac0088d9 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/CatalogueService.cs
@@ -19,19 +19,21 @@ public class CatalogueService : BaseService, ICatalogueService
///
/// Defines the _facade.
///
- private readonly ILearningHubApiFacade facade;
+ private readonly IOpenApiFacade facade;
///
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
- /// The learningHubApiFacade.
+ /// The Open Api Http Client.
+ /// The openApiFacade.
public CatalogueService(
ILearningHubHttpClient learningHubHttpClient,
- ILearningHubApiFacade learningHubApiFacade)
+ IOpenApiHttpClient openApiHttpClient,
+ IOpenApiFacade openApiFacade)
: base(learningHubHttpClient)
{
- this.facade = learningHubApiFacade;
+ this.facade = openApiFacade;
}
///
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/ContentService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/ContentService.cs
index d49cd8422..ec983fffd 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/ContentService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/ContentService.cs
@@ -27,15 +27,17 @@ public class ContentService : BaseService, IContentService
///
private readonly IFileService fileService;
private readonly IAzureMediaService azureMediaService;
+ private readonly IOpenApiHttpClient openApiHttpClient;
///
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
+ /// The openApiHttpClient.
/// The fileService.
/// azureMediaService.
- public ContentService(ILearningHubHttpClient learningHubHttpClient, IFileService fileService, IAzureMediaService azureMediaService)
- : base(learningHubHttpClient)
+ public ContentService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, IFileService fileService, IAzureMediaService azureMediaService)
+ : base(learningHubHttpClient, openApiHttpClient)
{
this.fileService = fileService;
this.azureMediaService = azureMediaService;
@@ -48,7 +50,7 @@ public ContentService(ILearningHubHttpClient learningHubHttpClient, IFileService
/// The .
public async Task DiscardAsync(int pageId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/discard/{pageId}";
var response = await client.PutAsync(request, null).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
@@ -68,7 +70,7 @@ public async Task GetPageByIdAsync(int id, bool includeHidden = f
{
PageViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = !includeHidden ? $"content/page/{id}" : $"content/page-all/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -97,7 +99,7 @@ public async Task GetPageSectionDetailByIdAsync(int
{
PageSectionDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/page-section-detail/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -126,7 +128,7 @@ public async Task GetEditablePageSectionDetailByIdAs
{
PageSectionDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/editable-page-section-detail/{pageSectionId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -154,7 +156,7 @@ public async Task GetPagesAsync()
{
PageResultViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/pages";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -181,7 +183,7 @@ public async Task GetPagesAsync()
/// The .
public async Task PublishAsync(int pageId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/publish/{pageId}";
var response = await client.PutAsync(request, null).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
@@ -214,7 +216,7 @@ public async Task UpdatePageImageSectionDetailAsync(int pageId, PageImageSection
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/page-image-section-detail/{pageId}";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -232,7 +234,7 @@ public async Task UpdatePageImageSectionDetailAsync(int pageId, PageImageSection
/// The .
public async Task ChangeOrderAsync(UpdatePageSectionOrderModel requestViewModel)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = "content/change-order/";
var content = new StringContent(
JsonConvert.SerializeObject(requestViewModel),
@@ -259,7 +261,7 @@ public async Task ChangeOrderAsync(UpdatePageSectionOrderModel requestViewModel)
/// The .
public async Task CloneAsync(int pageSectionId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/clone/{pageSectionId}";
var response = await client.PutAsync(request, null).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
@@ -276,7 +278,7 @@ public async Task CloneAsync(int pageSectionId)
/// The .
public async Task HideAsync(int pageSectionId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/hide/{pageSectionId}";
var response = await client.PutAsync(request, null).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
@@ -293,7 +295,7 @@ public async Task HideAsync(int pageSectionId)
/// The .
public async Task UnHideAsync(int pageSectionId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/unhide/{pageSectionId}";
var response = await client.PutAsync(request, null).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
@@ -310,7 +312,7 @@ public async Task UnHideAsync(int pageSectionId)
/// The .
public async Task DeleteAsync(int pageSectionId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/delete/{pageSectionId}";
var response = await client.PutAsync(request, null).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized ||
@@ -376,7 +378,7 @@ public async Task> GetFileTypeAsync()
{
List fileTypeList = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetFileTypes";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -459,7 +461,7 @@ public async Task SaveAttributeFileDetailsAsync(FileCreateRequestViewModel
var json = JsonConvert.SerializeObject(fileCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/save-attribute-file";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -493,7 +495,7 @@ public async Task SaveVideoAssetAsync(FileCreateRequestViewModel fileCreate
var json = JsonConvert.SerializeObject(fileCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/save-video-asset";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -593,7 +595,7 @@ public async Task GetFileChunkDetail(int fileChunkDeta
{
FileChunkDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetFileChunkDetail/{fileChunkDetailId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -624,7 +626,7 @@ public async Task SaveFileChunkDetailsAsync(FileChunkDetailViewModel fileCh
var json = JsonConvert.SerializeObject(fileChunkDetailCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/SaveFileChunkDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -682,7 +684,7 @@ public async Task RegisterChunkedFileAsync(FileChunkRegisterMo
public async Task DeleteFileChunkDetailAsync(int fileChunkDetailId)
{
ApiResponse apiResponse = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteFileChunkDetail/{fileChunkDetailId}";
var response = await client.DeleteAsync(request).ConfigureAwait(false);
@@ -814,7 +816,7 @@ public async Task UpdateVideoAssetAsync(VideoAssetViewModel model)
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/update-video-asset";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -844,7 +846,7 @@ public async Task UpdateVideoAssetAsync(VideoAssetViewModel model)
/// The .
public async Task CreatePageSectionAsync(PageSectionViewModel requestViewModel)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = "content/create-page-section/";
var content = new StringContent(
JsonConvert.SerializeObject(requestViewModel),
@@ -874,7 +876,7 @@ public async Task CreatePageSectionAsync(PageSectionViewModel requestViewMo
/// The .
public async Task UpdatePageSectionDetailAsync(PageSectionDetailViewModel updateViewModel)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = "content/update-page-section-detail/";
var content = new StringContent(
JsonConvert.SerializeObject(updateViewModel),
@@ -899,7 +901,7 @@ public async Task GetPageSectionDetailVideoAssetById
{
PageSectionDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"content/page-section-detail-video/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/EventService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/EventService.cs
index 000fce940..db61e47e3 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/EventService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/EventService.cs
@@ -18,8 +18,9 @@ public class EventService : BaseService, IEventService
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
- public EventService(ILearningHubHttpClient learningHubHttpClient)
- : base(learningHubHttpClient)
+ /// The openApiHttpClient.
+ public EventService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient)
+ : base(learningHubHttpClient, openApiHttpClient)
{
}
@@ -30,7 +31,7 @@ public async Task Create(Event eventEntity)
var json = JsonConvert.SerializeObject(eventEntity);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Event/Create";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/HierarchyService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/HierarchyService.cs
index b408cb637..17b37999b 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/HierarchyService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/HierarchyService.cs
@@ -16,21 +16,21 @@ public class HierarchyService : BaseService, IHierarchyService
///
/// Defines the _facade.
///
- private readonly ILearningHubApiFacade facade;
+ private readonly IOpenApiFacade facade;
///
/// Initializes a new instance of the class.
///
/// The learning hub http client.
- /// The learningHubApiFacade.
+ /// The openApiFacade.
/// The logger.
public HierarchyService(
ILearningHubHttpClient learningHubHttpClient,
- ILearningHubApiFacade learningHubApiFacade,
+ IOpenApiFacade openApiFacade,
ILogger logger)
: base(learningHubHttpClient)
{
- this.facade = learningHubApiFacade;
+ this.facade = openApiFacade;
}
///
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/OpenApiHttpClient.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/OpenApiHttpClient.cs
new file mode 100644
index 000000000..5e8463cad
--- /dev/null
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/OpenApiHttpClient.cs
@@ -0,0 +1,39 @@
+namespace LearningHub.Nhs.AdminUI.Services
+{
+ using System.Net.Http;
+ using LearningHub.Nhs.AdminUI.Configuration;
+ using LearningHub.Nhs.AdminUI.Interfaces;
+ using LearningHub.Nhs.Caching;
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.Extensions.Logging;
+ using Microsoft.Extensions.Options;
+
+ ///
+ /// The open api http client.
+ ///
+ public class OpenApiHttpClient : BaseHttpClient, IOpenApiHttpClient
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The http context accessor.
+ /// The web settings.
+ /// The http client.
+ /// The logger.
+ /// The cache service.
+ public OpenApiHttpClient(
+ IHttpContextAccessor httpContextAccessor,
+ IOptions webSettings,
+ HttpClient client,
+ ILogger logger,
+ ICacheService cacheService)
+ : base(httpContextAccessor, webSettings.Value, client, logger, cacheService)
+ {
+ }
+
+ ///
+ /// Gets the open api url.
+ ///
+ public override string ApiUrl => this.WebSettings.OpenApiUrl;
+ }
+}
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/ProviderService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/ProviderService.cs
index eeb6976f9..cfdc4050b 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/ProviderService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/ProviderService.cs
@@ -24,19 +24,20 @@ public class ProviderService : BaseService, IProviderService
///
/// Defines the _facade.
///
- private readonly ILearningHubApiFacade facade;
+ private readonly IOpenApiFacade facade;
///
/// Initializes a new instance of the class.
///
/// The cache service.
/// Learning hub http client.
- /// The learningHubApiFacade.
- public ProviderService(ICacheService cacheService, ILearningHubHttpClient learningHubHttpClient, ILearningHubApiFacade learningHubApiFacade)
+ /// open api http client.
+ /// The openApiFacade.
+ public ProviderService(ICacheService cacheService, ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, IOpenApiFacade openApiFacade)
: base(learningHubHttpClient)
{
this.cacheService = cacheService;
- this.facade = learningHubApiFacade;
+ this.facade = openApiFacade;
}
///
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs
index 4c6e3fe46..038681c64 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/ResourceService.cs
@@ -24,8 +24,9 @@ public class ResourceService : BaseService, IResourceService
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
- public ResourceService(ILearningHubHttpClient learningHubHttpClient)
- : base(learningHubHttpClient)
+ /// The openApiHttpClient.
+ public ResourceService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient)
+ : base(learningHubHttpClient, openApiHttpClient)
{
}
@@ -50,7 +51,7 @@ public async Task> GetResourc
var filter = JsonConvert.SerializeObject(pagingRequestModel.Filter);
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var json = JsonConvert.SerializeObject(pagingRequestModel);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
@@ -82,7 +83,7 @@ public async Task> GetResourceVersionEventsA
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceVersionEvents/{resourceVersionId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -111,7 +112,7 @@ public async Task GetResourceVersionVa
{
ResourceVersionValidationResultViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceVersionValidationResult/{resourceVersionId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -140,7 +141,7 @@ public async Task GetResourceVersionDevIdDetailsA
{
ResourceVersionDevIdViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceVersionDevIdDetails/{resourceVersionId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -167,7 +168,7 @@ public async Task GetResourceVersionDevIdDetailsA
/// The .
public async Task DoesDevIdExistsAsync(string devId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DoesDevIdExists/{devId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -198,7 +199,7 @@ public async Task UpdateDevIdDetailsAsync(ResourceVersionDevIdViewModel model)
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateDevId";
var response = await client.PutAsync(request, stringContent).ConfigureAwait(false);
@@ -223,7 +224,7 @@ public async Task GetResourceVersionExtendedVi
{
ResourceVersionExtendedViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceVersionExtendedViewModel/{resourceVersionId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -252,7 +253,7 @@ public async Task> GetResourceVersionsAsync(int r
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceVersions/{resourceId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -283,7 +284,7 @@ public async Task RevertToDraft(int resourceVersion
var json = JsonConvert.SerializeObject(new { resourceVersionId });
var stringContent = new StringContent(resourceVersionId.ToString(), Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/RevertToDraft";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -335,7 +336,7 @@ public async Task TransferResourceOwnership(int res
var json = JsonConvert.SerializeObject(vm);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/TransferResourceOwnership";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -382,7 +383,7 @@ public async Task UnpublishResourceVersionAsync(int
var json = JsonConvert.SerializeObject(vm);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UnpublishResourceVersion";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -433,7 +434,7 @@ public async Task CreateResourceVersionEvent(int re
var json = JsonConvert.SerializeObject(vm);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/CreateResourceVersionEvent";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/UserGroupService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/UserGroupService.cs
index 45dff59de..0a941c761 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/UserGroupService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/UserGroupService.cs
@@ -32,15 +32,17 @@ public class UserGroupService : BaseService, IUserGroupService
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
+ /// The Open Api Http Client.
/// The http context accessor.
/// The cacheService.
/// The roleService.
public UserGroupService(
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
ICacheService cacheService,
IRoleService roleService,
IHttpContextAccessor contextAccessor)
- : base(learningHubHttpClient)
+ : base(learningHubHttpClient, openApiHttpClient)
{
this.contextAccessor = contextAccessor;
this.cacheService = cacheService;
@@ -112,7 +114,7 @@ public async Task GetUserGroupAdminDetailbyIdAsyn
{
UserGroupAdminDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/GetUserGroupAdminDetailById/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -141,7 +143,7 @@ public async Task> GetUserGroupAdminRoleDetailByIdA
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/GetUserGroupAdminRoleDetailById/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -171,7 +173,7 @@ public async Task CreateUserGroup(UserGroupAdminDet
var json = JsonConvert.SerializeObject(userGroup);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/CreateUserGroup";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -214,7 +216,7 @@ public async Task UpdateUserGroup(UserGroupAdminDet
var json = JsonConvert.SerializeObject(userGroup);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/UpdateUserGroup";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -258,7 +260,7 @@ public async Task DeleteUserGroup(int userGroupId)
var json = JsonConvert.SerializeObject(userGroup);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/DeleteUserGroup";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -308,7 +310,7 @@ public async Task AddUsersToUserGroup(int userGroup
var json = JsonConvert.SerializeObject(userUserGroups);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/AddUserUserGroups";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -359,7 +361,7 @@ public async Task AddUserGroupsToCatalogue(int cata
var json = JsonConvert.SerializeObject(roleUserGroups);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/AddRoleUserGroups";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -403,7 +405,7 @@ public async Task DeleteUserUserGroup(int userUserG
var json = JsonConvert.SerializeObject(userGroup);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/DeleteUserUserGroup";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -447,7 +449,7 @@ public async Task DeleteRoleUserGroup(int roleUserG
var json = JsonConvert.SerializeObject(roleUserGroupUpdate);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/DeleteRoleUserGroup";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -502,7 +504,7 @@ public async Task> GetUserUserGroupPageAs
var filter = JsonConvert.SerializeObject(pagingRequestModel.Filter);
var presetFilter = JsonConvert.SerializeObject(pagingRequestModel.PresetFilter);
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/GetUserUserGroupAdminFilteredPage"
+ $"/{pagingRequestModel.Page}"
@@ -551,7 +553,7 @@ public async Task> GetRoleUserGroupPageAs
var filter = JsonConvert.SerializeObject(pagingRequestModel.Filter);
var presetFilter = JsonConvert.SerializeObject(pagingRequestModel.PresetFilter);
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/GetRoleUserGroupAdminFilteredPage"
+ $"/{pagingRequestModel.Page}"
@@ -598,7 +600,7 @@ private async Task> FetchRoleUserGroupDetailAsync()
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/GetUserGroupRoleDetail";
var response = await client.GetAsync(request).ConfigureAwait(false);
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/Services/UserService.cs b/AdminUI/LearningHub.Nhs.AdminUI/Services/UserService.cs
index 7c64fd2c0..c84dbc2f2 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/Services/UserService.cs
+++ b/AdminUI/LearningHub.Nhs.AdminUI/Services/UserService.cs
@@ -31,10 +31,11 @@ public class UserService : BaseService, IUserService
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
+ /// The openApiHttpClient .
/// The CacheService .
/// The userApiHttpClient .
- public UserService(ILearningHubHttpClient learningHubHttpClient, ICacheService cacheService, IUserApiHttpClient userApiHttpClient)
- : base(learningHubHttpClient)
+ public UserService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ICacheService cacheService, IUserApiHttpClient userApiHttpClient)
+ : base(learningHubHttpClient, openApiHttpClient)
{
this.cacheService = cacheService;
this.userApiHttpClient = userApiHttpClient;
@@ -166,7 +167,7 @@ public async Task GetEmailAddressRegistrationStatusAsyn
var filter = JsonConvert.SerializeObject(pagingRequestModel.Filter);
var presetFilter = JsonConvert.SerializeObject(pagingRequestModel.PresetFilter);
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"User/GetLHUserAdminBasicFilteredPage"
+ $"/{pagingRequestModel.Page}"
@@ -274,7 +275,7 @@ public async Task> GetUserCon
var modelString = JsonConvert.SerializeObject(pagingRequestModel);
var content = new StringContent(modelString, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceAdminSearchFilteredPage";
@@ -459,7 +460,7 @@ public async Task AddUserGroupsToUser(int userId, s
var json = JsonConvert.SerializeObject(userUserGroups);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/AddUserUserGroups";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -565,7 +566,7 @@ public async Task> GetUserLearni
var filter = JsonConvert.SerializeObject(pagingRequestModel.Filter);
var presetFilter = JsonConvert.SerializeObject(pagingRequestModel.PresetFilter);
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserLearningRecord/GetUserLearningRecords"
+ $"/{pagingRequestModel.Page}"
diff --git a/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json b/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json
index b3a5c0f9c..95a04b8bc 100644
--- a/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json
+++ b/AdminUI/LearningHub.Nhs.AdminUI/appsettings.json
@@ -17,6 +17,7 @@
"ELfhHubUrl": "",
"LearningHubApiUrl": "",
"UserApiUrl": "",
+ "OpenApiUrl": "",
"LearningHubAdminUrl": "",
"LogConfigDir": "D:\\learningHub\\NLog",
"AuthenticationServiceUrl": "",
diff --git a/LearningHub.Nhs.WebUI/Configuration/Settings.cs b/LearningHub.Nhs.WebUI/Configuration/Settings.cs
index ccb06c921..e300e80e3 100644
--- a/LearningHub.Nhs.WebUI/Configuration/Settings.cs
+++ b/LearningHub.Nhs.WebUI/Configuration/Settings.cs
@@ -31,6 +31,11 @@ public Settings()
///
public string LearningHubApiUrl { get; set; }
+ ///
+ /// Gets or sets the OpenApiUrl.
+ ///
+ public string OpenApiUrl { get; set; }
+
///
/// Gets or sets the UserApiUrl.
///
diff --git a/LearningHub.Nhs.WebUI/Controllers/SearchController.cs b/LearningHub.Nhs.WebUI/Controllers/SearchController.cs
index ff1afba0d..a7b53fb11 100644
--- a/LearningHub.Nhs.WebUI/Controllers/SearchController.cs
+++ b/LearningHub.Nhs.WebUI/Controllers/SearchController.cs
@@ -81,7 +81,7 @@ public async Task Index(SearchRequestViewModel search, bool noSor
if (filterApplied)
{
- await this.searchService.RegisterSearchEventsAsync(search, SearchFormActionTypeEnum.ApplyFilter, searchResult.ResourceSearchResult.TotalHits);
+ await this.searchService.RegisterSearchEventsAsync(search, SearchFormActionTypeEnum.ApplyFilter, searchResult.ResourceSearchResult?.TotalHits ?? 0);
}
if (noSortFilterError)
diff --git a/LearningHub.Nhs.WebUI/Helpers/IOpenApiFacade.cs b/LearningHub.Nhs.WebUI/Helpers/IOpenApiFacade.cs
new file mode 100644
index 000000000..a603461c7
--- /dev/null
+++ b/LearningHub.Nhs.WebUI/Helpers/IOpenApiFacade.cs
@@ -0,0 +1,59 @@
+namespace LearningHub.Nhs.WebUI.Helpers
+{
+ using System.Threading.Tasks;
+ using LearningHub.Nhs.Models.Common;
+
+ ///
+ /// Defines the .
+ ///
+ public interface IOpenApiFacade
+ {
+ ///
+ /// The GetAsync.
+ ///
+ /// The type.
+ /// The url.
+ /// The .
+ Task GetAsync(string url)
+ where T : class, new();
+
+ ///
+ /// The PostAsync.
+ ///
+ /// The type.
+ /// The url.
+ /// The body.
+ /// The .
+ Task PostAsync(string url, T body)
+ where T : class, new();
+
+ ///
+ /// The PostAsync.
+ ///
+ /// The type.
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ Task PostAsync(string url, TBody body)
+ where T : class, new()
+ where TBody : class, new();
+
+ ///
+ /// The PutAsync.
+ ///
+ /// The url.
+ /// The .
+ Task PutAsync(string url);
+
+ ///
+ /// The PutAsync.
+ ///
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ Task PutAsync(string url, T body)
+ where T : class, new();
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Helpers/OpenApiFacade.cs b/LearningHub.Nhs.WebUI/Helpers/OpenApiFacade.cs
new file mode 100644
index 000000000..32c529a0d
--- /dev/null
+++ b/LearningHub.Nhs.WebUI/Helpers/OpenApiFacade.cs
@@ -0,0 +1,241 @@
+namespace LearningHub.Nhs.WebUI.Helpers
+{
+ using System;
+ using System.Net.Http;
+ using System.Text;
+ using System.Threading.Tasks;
+ using LearningHub.Nhs.Models.Common;
+ using LearningHub.Nhs.WebUI.Interfaces;
+ using Newtonsoft.Json;
+
+ ///
+ /// Defines the .
+ ///
+ public class OpenApiFacade : IOpenApiFacade
+ {
+ ///
+ /// Defines the _client.
+ ///
+ private readonly IOpenApiHttpClient client;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The client.
+ public OpenApiFacade(IOpenApiHttpClient client)
+ {
+ this.client = client;
+ }
+
+ ///
+ /// The GetAsync.
+ ///
+ /// .
+ /// The url.
+ /// The .
+ public async Task GetAsync(string url)
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var vm = new T();
+
+ var response = await client.GetAsync(url).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ vm = JsonConvert.DeserializeObject(result);
+
+ return vm;
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("AccessDenied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PostAsync.
+ ///
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ public async Task PostAsync(string url, T body)
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
+ var response = await client.PostAsync(url, content).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ return;
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("AccessDenied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PostAsync.
+ ///
+ /// The return type.
+ /// The type of body parameter.
+ /// The url.
+ /// The body.
+ /// The .
+ public async Task PostAsync(string url, TBody body)
+ where TBody : class, new()
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var vm = new T();
+ var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
+ var response = await client.PostAsync(url, content).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ var apiResponse = JsonConvert.DeserializeObject(result);
+ if (apiResponse.Success)
+ {
+ return apiResponse;
+ }
+ else
+ {
+ string details = string.Empty;
+ if (apiResponse.ValidationResult != null)
+ {
+ if (apiResponse.ValidationResult.Details != null)
+ {
+ details = $"::ValidationResult: {string.Join(",", apiResponse.ValidationResult.Details)}";
+ }
+ }
+
+ throw new Exception($"PostAsync ApiResponse returned False: {details}");
+ }
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("Access Denied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PutAsync.
+ ///
+ /// The url.
+ /// The .
+ public async Task PutAsync(string url)
+ {
+ var client = await this.client.GetClientAsync();
+
+ var response = await client.PutAsync(url, null).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ var apiResponse = JsonConvert.DeserializeObject(result);
+ if (apiResponse.Success)
+ {
+ return apiResponse;
+ }
+ else
+ {
+ string details = string.Empty;
+ if (apiResponse.ValidationResult != null)
+ {
+ if (apiResponse.ValidationResult.Details != null)
+ {
+ details = $"::ValidationResult: {string.Join(",", apiResponse.ValidationResult.Details)}";
+ }
+ }
+
+ throw new Exception($"PutAsync ApiResponse returned False: {details}");
+ }
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("Access Denied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+
+ ///
+ /// The PutAsync.
+ ///
+ /// .
+ /// The url.
+ /// The body.
+ /// The .
+ public async Task PutAsync(string url, T body)
+ where T : class, new()
+ {
+ var client = await this.client.GetClientAsync();
+
+ var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
+ var response = await client.PutAsync(url, content).ConfigureAwait(false);
+
+ if (response.IsSuccessStatusCode)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+ var apiResponse = JsonConvert.DeserializeObject(result);
+ if (apiResponse.Success)
+ {
+ return apiResponse;
+ }
+ else
+ {
+ string details = string.Empty;
+ if (apiResponse.ValidationResult != null)
+ {
+ if (apiResponse.ValidationResult.Details != null)
+ {
+ details = $"::ValidationResult: {string.Join(",", apiResponse.ValidationResult.Details)}";
+ }
+ }
+
+ throw new Exception($"PutAsync ApiResponse returned False: {details}");
+ }
+ }
+ else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
+ ||
+ response.StatusCode == System.Net.HttpStatusCode.Forbidden)
+ {
+ throw new Exception("Access Denied");
+ }
+ else
+ {
+ throw new Exception($"Exception HttpStatusCode={response.StatusCode}");
+ }
+ }
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Interfaces/IOpenApiHttpClient.cs b/LearningHub.Nhs.WebUI/Interfaces/IOpenApiHttpClient.cs
new file mode 100644
index 000000000..4c53a2c38
--- /dev/null
+++ b/LearningHub.Nhs.WebUI/Interfaces/IOpenApiHttpClient.cs
@@ -0,0 +1,17 @@
+namespace LearningHub.Nhs.WebUI.Interfaces
+{
+ using System.Net.Http;
+ using System.Threading.Tasks;
+
+ ///
+ /// The OpenApiHttpClient interface.
+ ///
+ public interface IOpenApiHttpClient
+ {
+ ///
+ /// The get client.
+ ///
+ /// The .
+ Task GetClientAsync();
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Services/ActivityService.cs b/LearningHub.Nhs.WebUI/Services/ActivityService.cs
index a494bea91..185dc3a2c 100644
--- a/LearningHub.Nhs.WebUI/Services/ActivityService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ActivityService.cs
@@ -21,9 +21,10 @@ public class ActivityService : BaseService, IActivityService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// OpenApiHttpClient http client.
/// Logger.
- public ActivityService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public ActivityService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
diff --git a/LearningHub.Nhs.WebUI/Services/BaseService.cs b/LearningHub.Nhs.WebUI/Services/BaseService.cs
index 87d4cfc79..ddcbad86f 100644
--- a/LearningHub.Nhs.WebUI/Services/BaseService.cs
+++ b/LearningHub.Nhs.WebUI/Services/BaseService.cs
@@ -11,6 +11,7 @@ public abstract class BaseService
{
private readonly ILogger logger;
private readonly ILearningHubHttpClient learningHubHttpClient;
+ private readonly IOpenApiHttpClient openApiHttpClient;
///
/// Initializes a new instance of the class.
@@ -23,11 +24,29 @@ protected BaseService(ILearningHubHttpClient learningHubHttpClient, ILogger l
this.logger = logger;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The learningHubHttpClient.
+ /// The openApiHttpClient.
+ /// The logger.
+ protected BaseService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ {
+ this.learningHubHttpClient = learningHubHttpClient;
+ this.openApiHttpClient = openApiHttpClient;
+ this.logger = logger;
+ }
+
///
/// Gets the LearningHubHttpClient.
///
protected ILearningHubHttpClient LearningHubHttpClient => this.learningHubHttpClient;
+ ///
+ /// Gets the OpenApiHttpClient.
+ ///
+ protected IOpenApiHttpClient OpenApiHttpClient => this.openApiHttpClient;
+
///
/// Gets the Logger.
///
diff --git a/LearningHub.Nhs.WebUI/Services/BoomarkService.cs b/LearningHub.Nhs.WebUI/Services/BoomarkService.cs
index 5a26148cc..15d5509f9 100644
--- a/LearningHub.Nhs.WebUI/Services/BoomarkService.cs
+++ b/LearningHub.Nhs.WebUI/Services/BoomarkService.cs
@@ -19,16 +19,17 @@ public class BoomarkService : BaseService, IBookmarkService
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
+ /// The openApiHttpClient.
/// The logger.
- public BoomarkService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public BoomarkService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
///
public async Task Create(UserBookmarkViewModel bookmarkViewModel)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = "bookmark/Create";
var content = new StringContent(
JsonConvert.SerializeObject(bookmarkViewModel),
@@ -56,7 +57,7 @@ public async Task Create(UserBookmarkViewModel bookmarkViewModel)
///
public async Task Edit(UserBookmarkViewModel bookmarkViewModel)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = "bookmark/Edit";
var content = new StringContent(
JsonConvert.SerializeObject(bookmarkViewModel),
@@ -84,7 +85,7 @@ public async Task Edit(UserBookmarkViewModel bookmarkViewModel)
///
public async Task DeleteFolder(int bookmarkId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"bookmark/deletefolder/{bookmarkId}";
var response = await client.DeleteAsync(request).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
@@ -98,7 +99,7 @@ public async Task DeleteFolder(int bookmarkId)
///
public async Task> GetAllByParent(int? parentId, bool? all = false)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"bookmark/GetAllByParent/{parentId}?all={all}";
var response = await client.GetAsync(request).ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
@@ -120,7 +121,7 @@ public async Task> GetAllByParent(int? parent
///
public async Task Toggle(UserBookmarkViewModel bookmarkViewModel)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = "bookmark/toggle";
var content = new StringContent(
JsonConvert.SerializeObject(bookmarkViewModel),
diff --git a/LearningHub.Nhs.WebUI/Services/CardService.cs b/LearningHub.Nhs.WebUI/Services/CardService.cs
index d0795c0ad..d3aac0616 100644
--- a/LearningHub.Nhs.WebUI/Services/CardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/CardService.cs
@@ -19,9 +19,10 @@ public class CardService : BaseService, ICardService
/// Initializes a new instance of the class.
///
/// The Learning Hub Http Client.
+ /// The Open Api Http Client.
/// The logger.
- public CardService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public CardService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
@@ -34,7 +35,7 @@ public async Task GetMyContributionsTotalsAsync(
{
MyContributionsTotalsViewModel totals = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetMyContributionsTotals/{catalogueId.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -63,7 +64,7 @@ public async Task> GetContributionsAsync(
{
List myContributionCards = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var json = JsonConvert.SerializeObject(resourceContributionsRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
@@ -94,7 +95,7 @@ public async Task GetMyResourceViewModelAsync()
{
MyResourceViewModel myresourcecards = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetMyResourceViewModel";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -123,7 +124,7 @@ public async Task GetResourceCardExtendedViewMode
{
ResourceCardExtendedViewModel resourceCardExtendedViewModel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/ResourceCardExtendedViewModel/{id.ToString()}";
var response = await client.GetAsync(request).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/CatalogueService.cs b/LearningHub.Nhs.WebUI/Services/CatalogueService.cs
index a8a6d3055..3833a4e28 100644
--- a/LearningHub.Nhs.WebUI/Services/CatalogueService.cs
+++ b/LearningHub.Nhs.WebUI/Services/CatalogueService.cs
@@ -25,10 +25,11 @@ public class CatalogueService : BaseService, ICatalogueService
/// Initializes a new instance of the class.
///
/// The learning hub http client.
+ /// The Open Api Http Client.
/// The logger.
/// The cacheService.
- public CatalogueService(ILearningHubHttpClient learningHubHttpClient, ILogger logger, ICacheService cacheService)
- : base(learningHubHttpClient, logger)
+ public CatalogueService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger, ICacheService cacheService)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.cacheService = cacheService;
}
@@ -41,7 +42,7 @@ public async Task> GetCataloguesForUserAsync()
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Catalogue/GetForCurrentUser";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -70,7 +71,7 @@ public async Task GetCatalogueAsync(string reference)
{
CatalogueViewModel viewmodel = new CatalogueViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"catalogue/catalogue/{reference}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -98,7 +99,7 @@ public async Task GetCatalogueAsync(int catalogueNodeVersion
{
CatalogueViewModel viewmodel = new CatalogueViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"catalogue/catalogues/{catalogueNodeVersionId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -126,7 +127,7 @@ public async Task GetCatalogueRecordedAsync(string reference
{
CatalogueViewModel viewmodel = new CatalogueViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"catalogue/catalogue-recorded/{reference}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -154,7 +155,7 @@ public async Task GetResourcesAsync(Catalogu
{
CatalogueResourceResponseViewModel viewmodel = new CatalogueResourceResponseViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var json = JsonConvert.SerializeObject(requestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
@@ -185,7 +186,7 @@ public async Task CanCurrentUserEditCatalogue(int catalogueId)
{
var request = $"Catalogue/CanCurrentUserEditCatalogue/{catalogueId}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var response = await client.GetAsync(request).ConfigureAwait(false);
var catalogueIsEditable = false;
@@ -213,7 +214,7 @@ public async Task AccessDetailsAsync(string ref
{
var request = $"Catalogue/AccessDetails/{reference}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var response = await client.GetAsync(request).ConfigureAwait(false);
var accessDetails = new CatalogueAccessDetailsViewModel();
@@ -241,7 +242,7 @@ public async Task GetLatestCatalogueAccessReque
{
var request = $"Catalogue/GetLatestCatalogueAccessRequest/{catalogueNodeId}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var response = await client.GetAsync(request).ConfigureAwait(false);
var car = new CatalogueAccessRequestViewModel();
@@ -275,7 +276,7 @@ public async Task RequestAccessAsync(string referen
{
var request = $"Catalogue/RequestAccess/{reference}/{accessType}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var content = new StringContent(JsonConvert.SerializeObject(vm), Encoding.UTF8, "application/json");
var response = await client.PostAsync(request, content).ConfigureAwait(false);
var catalogueAccessRequested = false;
@@ -308,7 +309,7 @@ public async Task InviteUserAsync(RestrictedCatalog
{
var request = $"Catalogue/InviteUser";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var content = new StringContent(JsonConvert.SerializeObject(vm), Encoding.UTF8, "application/json");
var response = await client.PostAsync(request, content).ConfigureAwait(false);
var catalogueAccessRequested = false;
@@ -344,7 +345,7 @@ public async Task> GetRestricted
var json = JsonConvert.SerializeObject(requestModel);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Catalogue/GetRestrictedCatalogueAccessRequests";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -377,7 +378,7 @@ public async Task GetRestrictedCatalogueSum
{
var viewmodel = new RestrictedCatalogueSummaryViewModel();
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"catalogue/GetRestrictedCatalogueSummary/{catalogueNodeId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -412,7 +413,7 @@ public async Task GetRestrictedCatalogueUsers
var json = JsonConvert.SerializeObject(requestModel);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Catalogue/GetRestrictedCatalogueUsers";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -446,7 +447,7 @@ public async Task AcceptAccessRequestAsync(int acce
{
var request = $"Catalogue/AcceptAccessRequest/{accessRequestId}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var content = new StringContent(JsonConvert.SerializeObject(new { }));
var response = await client.PostAsync(request, content).ConfigureAwait(false);
var catalogueAccessRequested = new LearningHubValidationResult();
@@ -478,7 +479,7 @@ public async Task RejectAccessRequestAsync(int acce
{
var request = $"Catalogue/RejectAccessRequest/{accessRequestId}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var content = new StringContent(JsonConvert.SerializeObject(new CatalogueAccessRejectionViewModel { RejectionReason = rejectionReason }), Encoding.UTF8, "application/json");
var response = await client.PostAsync(request, content).ConfigureAwait(false);
var vr = new LearningHubValidationResult();
@@ -507,7 +508,7 @@ public async Task DismissAccessRequestAsync(int cat
{
var request = $"Catalogue/DismissAccessRequest/{catalogueNodeId}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var content = new StringContent(JsonConvert.SerializeObject(new { }));
var response = await client.PostAsync(request, content).ConfigureAwait(false);
var vr = new LearningHubValidationResult(false);
@@ -536,7 +537,7 @@ public async Task GetCatalogueAccessRequestAsyn
{
var request = $"Catalogue/AccessRequest/{catalogueAccessRequestId}";
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var response = await client.GetAsync(request).ConfigureAwait(false);
var catalogueAccessRequest = new CatalogueAccessRequestViewModel();
@@ -570,7 +571,7 @@ public async Task RemoveUserFromRestrictedAccessUse
var json = JsonConvert.SerializeObject(userGroup);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserGroup/DeleteUserUserGroup";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -611,7 +612,7 @@ public async Task RemoveUserFromRestrictedAccessUse
public async Task GetAllCatalogueAsync(string filterChar)
{
AllCatalogueResponseViewModel viewmodel = new AllCatalogueResponseViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"catalogue/allcatalogues/{filterChar}";
var response = await client.GetAsync(request).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/ContentService.cs b/LearningHub.Nhs.WebUI/Services/ContentService.cs
index 92fe7a7dd..b6d1f9296 100644
--- a/LearningHub.Nhs.WebUI/Services/ContentService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ContentService.cs
@@ -18,10 +18,11 @@ public class ContentService : BaseService, IContentService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
/// azureMediaService.
- public ContentService(ILearningHubHttpClient learningHubHttpClient, ILogger logger, IAzureMediaService azureMediaService)
- : base(learningHubHttpClient, logger)
+ public ContentService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger, IAzureMediaService azureMediaService)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.azureMediaService = azureMediaService;
}
@@ -36,7 +37,7 @@ public async Task GetPageByIdAsync(int id, bool preview)
{
PageViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var response = await client.GetAsync($"content/page/{id}?publishedOnly={!preview}&preview={preview}").ConfigureAwait(false);
@@ -63,7 +64,7 @@ public async Task GetPageSectionDetailVideoAssetById
{
PageSectionDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var response = await client.GetAsync($"content/page-section-detail-video/{id}").ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/ContributeService.cs b/LearningHub.Nhs.WebUI/Services/ContributeService.cs
index a61487e4e..68a2b4cf6 100644
--- a/LearningHub.Nhs.WebUI/Services/ContributeService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ContributeService.cs
@@ -39,9 +39,10 @@ public class ContributeService : BaseService, IContributeServ
/// Azure media service.
/// MKIO media service.
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
- public ContributeService(IFileService fileService, IResourceService resourceService, IAzureMediaService azureMediaService, ILearningHubHttpClient learningHubHttpClient, ILogger logger, IAzureMediaService mediaService)
- : base(learningHubHttpClient, logger)
+ public ContributeService(IFileService fileService, IResourceService resourceService, IAzureMediaService azureMediaService, ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger, IAzureMediaService mediaService)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.fileService = fileService;
this.resourceService = resourceService;
@@ -62,7 +63,7 @@ public async Task CreateNewResourceVersionAsync(int
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/CreateNewResourceVersion";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -96,7 +97,7 @@ public async Task CreateResourceAuthorAsync(ResourceAuthorViewModel resourc
var json = JsonConvert.SerializeObject(resourceAuthorViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/AddResourceVersionAuthor";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -130,7 +131,7 @@ public async Task CreateResourceKeywordAsync(ResourceKeywordViewModel resou
var json = JsonConvert.SerializeObject(resourceKeywordViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/AddResourceVersionKeyword";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -163,7 +164,7 @@ public async Task DeleteArticleFileAsync(FileDeleteRequestModel model)
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteArticleFile";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -193,7 +194,7 @@ public async Task DeleteArticleFileAsync(FileDeleteRequestModel model)
/// The .
public async Task DeleteFileChunkDetailAsync(int fileChunkDetailId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteFileChunkDetail/{fileChunkDetailId}";
var response = await client.DeleteAsync(request).ConfigureAwait(false);
@@ -224,7 +225,7 @@ public async Task DeleteResourceAttributeFileAsync(FileDeleteRequestModel
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteResourceAttributeFile";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -257,7 +258,7 @@ public async Task DeleteResourceAuthorAsync(AuthorDeleteRequestModel model
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteResourceVersionAuthor";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -290,7 +291,7 @@ public async Task DeleteResourceKeywordAsync(KeywordDeleteRequestModel mod
var json = JsonConvert.SerializeObject(model);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteResourceVersionKeyword";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -320,7 +321,7 @@ public async Task DeleteResourceKeywordAsync(KeywordDeleteRequestModel mod
/// The .
public async Task DeleteResourceVersionAsync(int resourceVersionId)
{
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/DeleteResourceVersion/{resourceVersionId}";
var response = await client.DeleteAsync(request).ConfigureAwait(false);
@@ -356,7 +357,7 @@ public async Task GetFileChunkDetail(int fileChunkDeta
{
FileChunkDetailViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetFileChunkDetail/{fileChunkDetailId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -799,7 +800,7 @@ public async Task SaveArticleAttachedFileDetailsAsync(FileCreateRequestView
var json = JsonConvert.SerializeObject(fileCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/SaveArticleAttachedFileDetails";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -833,7 +834,7 @@ public async Task SaveArticleDetailAsync(ArticleUpdateRequestViewModel arti
var json = JsonConvert.SerializeObject(articleViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateArticleDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -867,7 +868,7 @@ public async Task SaveFileChunkDetailsAsync(FileChunkDetailViewModel fileCh
var json = JsonConvert.SerializeObject(fileChunkDetailCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/SaveFileChunkDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -901,7 +902,7 @@ public async Task SaveFileDetailsAsync(FileCreateRequestViewModel fileCreat
var json = JsonConvert.SerializeObject(fileCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/SaveFileDetails";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -935,7 +936,7 @@ public async Task SaveGenericFileDetailAsync(GenericFileUpdateRequestViewMo
var json = JsonConvert.SerializeObject(genericFileViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateGenericFileDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -969,7 +970,7 @@ public async Task SaveScormDetailAsync(ScormUpdateRequestViewModel scormUpd
var json = JsonConvert.SerializeObject(scormUpdateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateScormDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1003,7 +1004,7 @@ public async Task SaveHtmlDetailAsync(HtmlResourceUpdateRequestViewModel ht
var json = JsonConvert.SerializeObject(htmlResource);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateHtmlDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1037,7 +1038,7 @@ public async Task SaveImageDetailAsync(ImageUpdateRequestViewModel imageVie
var json = JsonConvert.SerializeObject(imageViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateImageDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1071,7 +1072,7 @@ public async Task SaveResourceAttributeFileDetailsAsync(FileCreateRequestVi
var json = JsonConvert.SerializeObject(fileCreateRequestViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/SaveResourceAttributeFileDetails";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1128,7 +1129,7 @@ public async Task SaveWeblinkDetailAsync(WebLinkViewModel weblinkViewModel)
var json = JsonConvert.SerializeObject(weblinkViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateWeblinkDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1162,7 +1163,7 @@ public async Task SaveCaseDetailAsync(CaseViewModel caseViewModel)
var json = JsonConvert.SerializeObject(caseViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateCaseDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1196,7 +1197,7 @@ public async Task SaveAssessmentDetailAsync(AssessmentViewModel assessmentV
var json = JsonConvert.SerializeObject(assessmentViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateAssessmentDetail";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1230,7 +1231,7 @@ public async Task SubmitResourceVersionForPublishAs
var json = JsonConvert.SerializeObject(publishViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/SubmitResourceVersionForPublish";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1335,7 +1336,7 @@ private async Task CreateResourceAsync(ResourceDetailViewModel resourceDeta
var json = JsonConvert.SerializeObject(resourceDetailViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/CreateResource";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -1368,7 +1369,7 @@ private async Task UpdateResourceVersionAsync(ResourceDetailViewModel resourceDe
var json = JsonConvert.SerializeObject(resourceDetailViewModel);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/UpdateResourceVersion";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/CountryService.cs b/LearningHub.Nhs.WebUI/Services/CountryService.cs
index 2c0c7e120..e1afd4b35 100644
--- a/LearningHub.Nhs.WebUI/Services/CountryService.cs
+++ b/LearningHub.Nhs.WebUI/Services/CountryService.cs
@@ -20,13 +20,15 @@ public class CountryService : BaseService, ICountryService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// User api http client.
/// Logger.
public CountryService(
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
IUserApiHttpClient userApiHttpClient,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.userApiHttpClient = userApiHttpClient;
}
diff --git a/LearningHub.Nhs.WebUI/Services/DashboardService.cs b/LearningHub.Nhs.WebUI/Services/DashboardService.cs
index 55f5153bf..607d4f2be 100644
--- a/LearningHub.Nhs.WebUI/Services/DashboardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/DashboardService.cs
@@ -26,10 +26,11 @@ public class DashboardService : BaseService, IDashboardService
/// Initializes a new instance of the class.
///
/// learningHubHttpClient.
+ /// The Open Api Http Client.
/// logger.
/// MoodleHttpClient.
- public DashboardService(ILearningHubHttpClient learningHubHttpClient, ILogger logger, IMoodleHttpClient moodleHttpClient)
- : base(learningHubHttpClient, logger)
+ public DashboardService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger, IMoodleHttpClient moodleHttpClient)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.moodleHttpClient = moodleHttpClient;
}
@@ -44,7 +45,7 @@ public async Task GetMyAccessLearningsAsyn
{
DashboardMyLearningResponseViewModel viewmodel = new DashboardMyLearningResponseViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"dashboard/myaccesslearning/{dashboardType}/{pageNumber}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -73,7 +74,7 @@ public async Task GetCataloguesAsync(string
{
DashboardCatalogueResponseViewModel viewmodel = new DashboardCatalogueResponseViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"dashboard/catalogues/{dashboardType}/{pageNumber}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -102,7 +103,7 @@ public async Task GetResourcesAsync(string d
{
DashboardResourceResponseViewModel viewmodel = new DashboardResourceResponseViewModel { };
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"dashboard/resources/{dashboardType}/{pageNumber}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -149,7 +150,7 @@ public async Task RecordDashBoardEventAsync(DashboardEventViewModel dashboardEve
};
var content = new System.Net.Http.StringContent(JsonConvert.SerializeObject(eventEntity), Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"event/Create";
var response = await client.PostAsync(request, content).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs b/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs
index da62c5cbd..e9bf607ce 100644
--- a/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs
+++ b/LearningHub.Nhs.WebUI/Services/DetectJsLogService.cs
@@ -14,9 +14,10 @@ public class DetectJsLogService : BaseService, IDetectJsLogS
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
- public DetectJsLogService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public DetectJsLogService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
diff --git a/LearningHub.Nhs.WebUI/Services/GradeService.cs b/LearningHub.Nhs.WebUI/Services/GradeService.cs
index fb0a42074..37df9b048 100644
--- a/LearningHub.Nhs.WebUI/Services/GradeService.cs
+++ b/LearningHub.Nhs.WebUI/Services/GradeService.cs
@@ -19,13 +19,15 @@ public class GradeService : BaseService, IGradeService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// User api http client.
/// Logger.
public GradeService(
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
IUserApiHttpClient userApiHttpClient,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.userApiHttpClient = userApiHttpClient;
}
diff --git a/LearningHub.Nhs.WebUI/Services/HierarchyService.cs b/LearningHub.Nhs.WebUI/Services/HierarchyService.cs
index 4bd8f7734..6bed5fd27 100644
--- a/LearningHub.Nhs.WebUI/Services/HierarchyService.cs
+++ b/LearningHub.Nhs.WebUI/Services/HierarchyService.cs
@@ -16,21 +16,23 @@ public class HierarchyService : BaseService, IHierarchyService
///
/// Defines the _facade.
///
- private readonly ILearningHubApiFacade facade;
+ private readonly IOpenApiFacade facade;
///
/// Initializes a new instance of the class.
///
/// The learning hub http client.
- /// The learningHubApiFacade.
+ /// The Open Api Http Client.
+ /// The openApiFacade.
/// The logger.
public HierarchyService(
ILearningHubHttpClient learningHubHttpClient,
- ILearningHubApiFacade learningHubApiFacade,
+ IOpenApiHttpClient openApiHttpClient,
+ IOpenApiFacade openApiFacade,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
- this.facade = learningHubApiFacade;
+ this.facade = openApiFacade;
}
///
diff --git a/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs b/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs
index d578d9523..bb19a0f38 100644
--- a/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs
+++ b/LearningHub.Nhs.WebUI/Services/InternalSystemService.cs
@@ -16,9 +16,10 @@ public class InternalSystemService : BaseService, IIntern
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
- public InternalSystemService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public InternalSystemService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
diff --git a/LearningHub.Nhs.WebUI/Services/JobRoleService.cs b/LearningHub.Nhs.WebUI/Services/JobRoleService.cs
index bbf9f4402..766d05e60 100644
--- a/LearningHub.Nhs.WebUI/Services/JobRoleService.cs
+++ b/LearningHub.Nhs.WebUI/Services/JobRoleService.cs
@@ -22,13 +22,15 @@ public class JobRoleService : BaseService, IJobRoleService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// User api http client.
/// Logger.
public JobRoleService(
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
IUserApiHttpClient userApiHttpClient,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.userApiHttpClient = userApiHttpClient;
}
diff --git a/LearningHub.Nhs.WebUI/Services/LocationService.cs b/LearningHub.Nhs.WebUI/Services/LocationService.cs
index 2ba678ab0..04423a0b6 100644
--- a/LearningHub.Nhs.WebUI/Services/LocationService.cs
+++ b/LearningHub.Nhs.WebUI/Services/LocationService.cs
@@ -19,13 +19,15 @@ public class LocationService : BaseService, ILocationService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// User api http client.
/// Logger.
public LocationService(
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
IUserApiHttpClient userApiHttpClient,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.userApiHttpClient = userApiHttpClient;
}
diff --git a/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs b/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs
index 306d69304..06fd7e428 100644
--- a/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs
+++ b/LearningHub.Nhs.WebUI/Services/LoginWizardService.cs
@@ -24,13 +24,15 @@ public class LoginWizardService : BaseService, ILoginWizardS
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// User api http client.
/// Logger.
public LoginWizardService(
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
IUserApiHttpClient userApiHttpClient,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.userApiHttpClient = userApiHttpClient;
}
diff --git a/LearningHub.Nhs.WebUI/Services/MyLearningService.cs b/LearningHub.Nhs.WebUI/Services/MyLearningService.cs
index c6f9f2ffb..1e1662201 100644
--- a/LearningHub.Nhs.WebUI/Services/MyLearningService.cs
+++ b/LearningHub.Nhs.WebUI/Services/MyLearningService.cs
@@ -20,9 +20,10 @@ public class MyLearningService : BaseService, IMyLearningServ
/// Initializes a new instance of the class.
///
/// The learningHubHttpClient.
+ /// The Open Api Http Client.
/// The logger.
- public MyLearningService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public MyLearningService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
@@ -38,7 +39,7 @@ public async Task GetActivityDetailed(MyLearningReq
var json = JsonConvert.SerializeObject(requestModel);
var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"MyLearning/GetActivityDetailed";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -67,7 +68,7 @@ public async Task GetActivityDetailed(MyLearningReq
public async Task> GetPlayedSegments(int resourceId, int majorVersion)
{
List viewModel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"MyLearning/GetPlayedSegments/{resourceId}/{majorVersion}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -98,7 +99,7 @@ public async Task> GetPlayedSegments(int resourceId
public async Task> GetResourceCertificateDetails(int resourceReferenceId, int? majorVersion = 0, int? minorVersion = 0, int? userId = 0)
{
Tuple viewModel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"MyLearning/GetResourceCertificateDetails/{resourceReferenceId}/{majorVersion}/{minorVersion}/{userId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/NotificationService.cs b/LearningHub.Nhs.WebUI/Services/NotificationService.cs
index d41ef30d6..e836edcd9 100644
--- a/LearningHub.Nhs.WebUI/Services/NotificationService.cs
+++ b/LearningHub.Nhs.WebUI/Services/NotificationService.cs
@@ -22,9 +22,10 @@ public class NotificationService : BaseService, INotificati
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
- public NotificationService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public NotificationService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
@@ -95,7 +96,7 @@ public async Task> GetPagedAsync(Pagin
{
PagedResultSet viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var content = new StringContent(JsonConvert.SerializeObject(pagingRequestModel), Encoding.UTF8, "application/json");
@@ -124,7 +125,7 @@ public async Task GetUserNotificationIdAsync(int id)
{
UserNotification viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserNotification/GetById/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -153,7 +154,7 @@ public async Task GetUserNotificationDetailsAsync(int id)
{
UserNotification viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserNotification/GetByIdAndUserId/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -182,7 +183,7 @@ public async Task GetUserUnreadNotificationCountAsync(int userid)
{
int count = 0;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserNotification/GetUserUnreadNotificationCount/{userid}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -212,7 +213,7 @@ private async Task PutAsync(UserNotification notification)
var json = JsonConvert.SerializeObject(notification);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserNotification/PutAsync";
var response = await client.PutAsync(request, stringContent).ConfigureAwait(false);
@@ -245,7 +246,7 @@ private async Task PostAsync(UserNotification notification)
var json = JsonConvert.SerializeObject(notification);
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"UserNotification/PostAsync";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/OpenApiHttpClient.cs b/LearningHub.Nhs.WebUI/Services/OpenApiHttpClient.cs
new file mode 100644
index 000000000..54c3b7bb2
--- /dev/null
+++ b/LearningHub.Nhs.WebUI/Services/OpenApiHttpClient.cs
@@ -0,0 +1,41 @@
+namespace LearningHub.Nhs.WebUI.Services
+{
+ using System.Net.Http;
+ using LearningHub.Nhs.Caching;
+ using LearningHub.Nhs.WebUI.Configuration;
+ using LearningHub.Nhs.WebUI.Interfaces;
+ using Microsoft.AspNetCore.Http;
+ using Microsoft.Extensions.Logging;
+ using Microsoft.Extensions.Options;
+
+ ///
+ /// The open api http client.
+ ///
+ public class OpenApiHttpClient : BaseHttpClient, IOpenApiHttpClient
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The http context accessor.
+ /// The web settings.
+ /// The auth config.
+ /// The http client.
+ /// The logger.
+ /// The cache service.
+ public OpenApiHttpClient(
+ IHttpContextAccessor httpContextAccessor,
+ IOptions webSettings,
+ LearningHubAuthServiceConfig authConfig,
+ HttpClient client,
+ ILogger logger,
+ ICacheService cacheService)
+ : base(httpContextAccessor, webSettings.Value, authConfig, client, logger, cacheService)
+ {
+ }
+
+ ///
+ /// Gets the open api url.
+ ///
+ public override string ApiUrl => this.WebSettings.OpenApiUrl;
+ }
+}
diff --git a/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs b/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs
index 7a7a33616..5ef45d685 100644
--- a/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs
+++ b/LearningHub.Nhs.WebUI/Services/PartialFileUploadService.cs
@@ -34,12 +34,14 @@ public class PartialFileUploadService : BaseService, I
///
/// The Settings.
/// The learning hub http client.
+ /// The Open Api Http Client.
/// The logger.
public PartialFileUploadService(
IOptions settings,
ILearningHubHttpClient learningHubHttpClient,
+ IOpenApiHttpClient openApiHttpClient,
ILogger logger)
- : base(learningHubHttpClient, logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.settings = settings.Value;
}
diff --git a/LearningHub.Nhs.WebUI/Services/ProviderService.cs b/LearningHub.Nhs.WebUI/Services/ProviderService.cs
index 44a91495b..ee6119c60 100644
--- a/LearningHub.Nhs.WebUI/Services/ProviderService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ProviderService.cs
@@ -22,9 +22,10 @@ public class ProviderService : BaseService, IProviderService
///
/// The cache service.
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
- public ProviderService(ICacheService cacheService, ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public ProviderService(ICacheService cacheService, ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.cacheService = cacheService;
}
@@ -47,7 +48,7 @@ public async Task> GetProvidersForUserAsync(int userId)
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Provider/GetProvidersByUserId/{userId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -76,7 +77,7 @@ public async Task> GetProvidersForResourceAsync(int reso
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Provider/GetProvidersByResource/{resourceVersionId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -111,7 +112,7 @@ private async Task> GetAllProviders()
{
List viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Provider/all";
var response = await client.GetAsync(request).ConfigureAwait(false);
diff --git a/LearningHub.Nhs.WebUI/Services/RatingService.cs b/LearningHub.Nhs.WebUI/Services/RatingService.cs
index f08361096..fa72f4264 100644
--- a/LearningHub.Nhs.WebUI/Services/RatingService.cs
+++ b/LearningHub.Nhs.WebUI/Services/RatingService.cs
@@ -19,9 +19,10 @@ public class RatingService : BaseService, IRatingService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
- public RatingService(ILearningHubHttpClient learningHubHttpClient, ILogger logger)
- : base(learningHubHttpClient, logger)
+ public RatingService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
}
diff --git a/LearningHub.Nhs.WebUI/Services/RegionService.cs b/LearningHub.Nhs.WebUI/Services/RegionService.cs
index 6a48fcf5d..f05fc22eb 100644
--- a/LearningHub.Nhs.WebUI/Services/RegionService.cs
+++ b/LearningHub.Nhs.WebUI/Services/RegionService.cs
@@ -19,10 +19,11 @@ public class RegionService : BaseService, IRegionService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Logger.
/// User Api http client.
- public RegionService(ILearningHubHttpClient learningHubHttpClient, ILogger logger, IUserApiHttpClient userApiHttpClient)
- : base(learningHubHttpClient, logger)
+ public RegionService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, ILogger logger, IUserApiHttpClient userApiHttpClient)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.userApiHttpClient = userApiHttpClient;
}
diff --git a/LearningHub.Nhs.WebUI/Services/ResourceService.cs b/LearningHub.Nhs.WebUI/Services/ResourceService.cs
index 02a233ea0..ec8eaee30 100644
--- a/LearningHub.Nhs.WebUI/Services/ResourceService.cs
+++ b/LearningHub.Nhs.WebUI/Services/ResourceService.cs
@@ -34,11 +34,12 @@ public class ResourceService : BaseService, IResourceService
/// Initializes a new instance of the class.
///
/// Learning hub http client.
+ /// The Open Api Http Client.
/// Azure media services.
/// Logger.
/// Settings.
- public ResourceService(ILearningHubHttpClient learningHubHttpClient, IAzureMediaService azureMediaService, ILogger logger, IOptions settings)
- : base(learningHubHttpClient, logger)
+ public ResourceService(ILearningHubHttpClient learningHubHttpClient, IOpenApiHttpClient openApiHttpClient, IAzureMediaService azureMediaService, ILogger logger, IOptions settings)
+ : base(learningHubHttpClient, openApiHttpClient, logger)
{
this.settings = settings.Value;
this.azureMediaService = azureMediaService;
@@ -55,7 +56,7 @@ public async Task AcceptSensitiveContentAsync(int r
var stringContent = new StringContent(resourceVersionId.ToString(), Encoding.UTF8, "application/json");
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/AcceptSensitiveContent";
var response = await client.PostAsync(request, stringContent).ConfigureAwait(false);
@@ -87,7 +88,7 @@ public async Task GetArticleDetailsByIdAsync(int resourceVersi
{
ArticleViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetArticleDetails/{resourceVersionId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -116,7 +117,7 @@ public async Task GetAudioDetailsByIdAsync(int resourceVersionId
{
AudioViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetAudioDetails/{resourceVersionId}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -145,7 +146,7 @@ public async Task GetByIdAsync(int id)
{
ResourceHeaderViewModel viewmodel = null;
- var client = await this.LearningHubHttpClient.GetClientAsync();
+ var client = await this.OpenApiHttpClient.GetClientAsync();
var request = $"Resource/GetResourceHeaderViewModelAsync/{id}";
var response = await client.GetAsync(request).ConfigureAwait(false);
@@ -173,7 +174,7 @@ public async Task