diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Models/Configuration/AzureConfig.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Models/Configuration/AzureConfig.cs
index 9b3ad76d1..55832bb7b 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Models/Configuration/AzureConfig.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Models/Configuration/AzureConfig.cs
@@ -9,6 +9,7 @@ public class AzureConfig
/// Gets or sets the azure blob settings.
///
public AzureBlobSettings AzureBlobSettings { get; set; } = null!;
+
///
/// Gets or sets the azure storage queue.
///
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IResourceService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IResourceService.cs
index d71c89701..2a83eed80 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IResourceService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IResourceService.cs
@@ -225,6 +225,13 @@ Task GetAssessmentProgress(
/// If the user has published resources.
Task HasPublishedResourcesAsync(int userId);
+ ///
+ /// The get resource version by id async.
+ ///
+ /// The resourceVersionId.
+ /// The .
+ Task GetResourceVersionByIdAsync(int resourceVersionId);
+
///
/// The get resource by activityStatusIds async.
///
@@ -300,6 +307,14 @@ Task GetAssessmentProgress(
/// The .
Task GetCaseDetailsByIdAsync(int resourceVersionId);
+ ///
+ /// The GetExternalContentDetails.
+ ///
+ /// The resourceVersionId.
+ /// userId.
+ /// The .
+ Task GetExternalContentDetails(int resourceVersionId, int userId);
+
///
/// The get case resource version async.
///
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/ResourceService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/ResourceService.cs
index 7102145e5..07a55e537 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/ResourceService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/ResourceService.cs
@@ -521,6 +521,22 @@ public async Task GetCaseDetailsByIdAsync(int resourceVersionId)
return caseViewModel;
}
+ ///
+ /// The GetExternalContentDetails.
+ ///
+ /// The resourceVersionId.
+ /// userId.
+ /// The .
+ public async Task GetExternalContentDetails(int resourceVersionId, int userId)
+ {
+ var viewModel = await this.resourceVersionRepository.GetExternalContentDetails(resourceVersionId, userId);
+ if (viewModel != null)
+ {
+ viewModel.HostedContentUrl = $"{this.learningHubConfig.ContentServerUrl}/{viewModel.ExternalReference}/".ToLower();
+ }
+
+ return viewModel;
+ }
///
/// The GetFileStatusDetailsAsync.
@@ -667,6 +683,55 @@ public async Task> GetResourceLicencesAsync()
return licenceList;
}
+ ///
+ /// The get resource version by id async.
+ ///
+ /// The resourceVersionId.
+ /// The .
+ public async Task GetResourceVersionByIdAsync(int resourceVersionId)
+ {
+ var resourceVersion = await this.resourceVersionRepository.GetBasicByIdAsync(resourceVersionId);
+
+ var vm = this.mapper.Map(resourceVersion);
+
+ var nodeResources = await this.nodeResourceRepository.GetByResourceIdAsync(vm.ResourceId);
+ var draftNodeResources = nodeResources.Where(x => x.VersionStatusEnum == VersionStatusEnum.Draft).ToList();
+ var publishedNodeResources = nodeResources.Where(x => x.VersionStatusEnum == VersionStatusEnum.Published || x.VersionStatusEnum == VersionStatusEnum.Unpublished).ToList();
+
+ if (draftNodeResources.Count() == 0)
+ {
+ if (publishedNodeResources != null && publishedNodeResources.Count == 1)
+ {
+ vm.NodeId = publishedNodeResources[0].NodeId;
+ vm.ResourceCatalogueId = await this.nodePathRepository.GetCatalogueRootNodeId(publishedNodeResources[0].NodeId);
+ }
+ else
+ {
+ vm.NodeId = 0;
+ vm.ResourceCatalogueId = 0;
+ }
+ }
+ else if (draftNodeResources.Count() > 1)
+ {
+ throw new Exception("Resource must belong to a single catalogue. ResourceVersionId: " + vm.ResourceVersionId.ToString() + ". ResourceId: " + vm.ResourceId.ToString() + ", VersionStatusEnum:" + vm.VersionStatusEnum.ToString());
+ }
+ else
+ {
+ vm.NodeId = draftNodeResources[0].NodeId;
+ vm.ResourceCatalogueId = await this.nodePathRepository.GetCatalogueRootNodeId(draftNodeResources[0].NodeId);
+ }
+
+ if (publishedNodeResources != null && publishedNodeResources.Count == 1)
+ {
+ vm.PublishedResourceCatalogueId = await this.nodePathRepository.GetCatalogueRootNodeId(publishedNodeResources[0].NodeId);
+ }
+
+ vm.Flags = await this.GetResourceVersionFlagViewModels(resourceVersion.ResourceVersionFlag);
+
+ return vm;
+ }
+
+
///
/// The get resource version view model async.
///
@@ -1267,54 +1332,6 @@ public async Task HasPublishedResourcesAsync(int userId)
return await this.resourceRepository.UserHasPublishedResourcesAsync(userId);
}
- ///
- /// The get resource version by id async.
- ///
- /// The resourceVersionId.
- /// The .
- public async Task GetResourceVersionByIdAsync(int resourceVersionId)
- {
- var resourceVersion = await this.resourceVersionRepository.GetBasicByIdAsync(resourceVersionId);
-
- var vm = this.mapper.Map(resourceVersion);
-
- var nodeResources = await this.nodeResourceRepository.GetByResourceIdAsync(vm.ResourceId);
- var draftNodeResources = nodeResources.Where(x => x.VersionStatusEnum == VersionStatusEnum.Draft).ToList();
- var publishedNodeResources = nodeResources.Where(x => x.VersionStatusEnum == VersionStatusEnum.Published || x.VersionStatusEnum == VersionStatusEnum.Unpublished).ToList();
-
- if (draftNodeResources.Count() == 0)
- {
- if (publishedNodeResources != null && publishedNodeResources.Count == 1)
- {
- vm.NodeId = publishedNodeResources[0].NodeId;
- vm.ResourceCatalogueId = await this.nodePathRepository.GetCatalogueRootNodeId(publishedNodeResources[0].NodeId);
- }
- else
- {
- vm.NodeId = 0;
- vm.ResourceCatalogueId = 0;
- }
- }
- else if (draftNodeResources.Count() > 1)
- {
- throw new Exception("Resource must belong to a single catalogue. ResourceVersionId: " + vm.ResourceVersionId.ToString() + ". ResourceId: " + vm.ResourceId.ToString() + ", VersionStatusEnum:" + vm.VersionStatusEnum.ToString());
- }
- else
- {
- vm.NodeId = draftNodeResources[0].NodeId;
- vm.ResourceCatalogueId = await this.nodePathRepository.GetCatalogueRootNodeId(draftNodeResources[0].NodeId);
- }
-
- if (publishedNodeResources.Count == 1)
- {
- vm.PublishedResourceCatalogueId = await this.nodePathRepository.GetCatalogueRootNodeId(publishedNodeResources[0].NodeId);
- }
-
- vm.Flags = await this.GetResourceVersionFlagViewModels(resourceVersion.ResourceVersionFlag);
-
- return vm;
- }
-
///
/// The save resource version flag async.
///
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ResourceController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ResourceController.cs
index 9e8be7d55..f514d1f45 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ResourceController.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ResourceController.cs
@@ -281,6 +281,17 @@ public async Task GetCaseResourceVersionAsync(int resourceVersionI
return this.Ok(await this.resourceService.GetCaseDetailsByIdAsync(resourceVersionId));
}
+ ///
+ /// The GetExternalContentDetailsById.
+ ///
+ /// The resourceVersionId.
+ /// The .
+ [HttpGet("GetExternalContentDetailsById/{resourceVersionId}")]
+ public async Task GetScormContentDetailsById(int resourceVersionId)
+ {
+ return this.Ok(await this.resourceService.GetExternalContentDetails(resourceVersionId, this.CurrentUserId.GetValueOrDefault()));
+ }
+
///
/// The GetFileStatusDetailsAsync.
///
@@ -342,6 +353,17 @@ public async Task GetResourceLicences()
return this.Ok(await this.resourceService.GetResourceLicencesAsync());
}
+ ///
+ /// Get specific ResourceVersion by Id.
+ ///
+ /// The resourceVersionId.
+ /// The .
+ [HttpGet("GetResourceVersion/{resourceVersionId}")]
+ public async Task GetResourceVersionAsync(int resourceVersionId)
+ {
+ return this.Ok(await this.resourceService.GetResourceVersionByIdAsync(resourceVersionId));
+ }
+
///
/// Get specific ResourceVersionViewModel by Id.
///
@@ -798,7 +820,7 @@ public async Task DuplicateBlocks(DuplicateBlocksRequestModel dup
/// The .
[HttpPost]
[Route("CreateResource")]
- public async Task CreateResourceAsync(ResourceDetailViewModel viewModel)
+ public async Task CreateResourceAsync([FromBody] ResourceDetailViewModel viewModel)
{
var vr = await this.resourceService.CreateResourceAsync(viewModel, this.CurrentUserId.GetValueOrDefault());
if (vr.IsValid)
@@ -891,7 +913,7 @@ public async Task SubmitResourceVersionForPublishAsync(PublishVie
[HttpPost]
[Authorize(Policy = "ReadWrite")]
[Route("UpdateResourceVersion")]
- public async Task UpdateResourceVersionAsync(ResourceDetailViewModel resourceDetailViewModel)
+ public async Task UpdateResourceVersionAsync([FromBody] ResourceDetailViewModel resourceDetailViewModel)
{
var vr = await this.resourceService.UpdateResourceVersionAsync(resourceDetailViewModel, this.CurrentUserId.GetValueOrDefault());
@@ -1093,7 +1115,7 @@ public async Task DeleteResourceAttributeFileAsync(FileDeleteRequ
/// The .
[HttpPost]
[Route("UpdateAudioDetail")]
- public async Task UpdateAudioDetailAsync(AudioUpdateRequestViewModel audioViewModel)
+ public async Task UpdateAudioDetailAsync([FromBody] AudioUpdateRequestViewModel audioViewModel)
{
var vr = await this.resourceService.UpdateAudioDetailAsync(audioViewModel, this.CurrentUserId.GetValueOrDefault());
@@ -1114,7 +1136,7 @@ public async Task UpdateAudioDetailAsync(AudioUpdateRequestViewMo
/// The .
[HttpPost]
[Route("UpdateArticleDetail")]
- public async Task UpdateArticleDetailAsync(ArticleUpdateRequestViewModel articleViewModel)
+ public async Task UpdateArticleDetailAsync([FromBody] ArticleUpdateRequestViewModel articleViewModel)
{
var vr = await this.resourceService.UpdateArticleDetailAsync(articleViewModel, this.CurrentUserId.GetValueOrDefault());
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json b/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json
index 741ead5fa..1fd6fa2d1 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json
+++ b/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json
@@ -3554,6 +3554,31 @@
}
}
},
+ "/Resource/GetExternalContentDetailsById/{resourceVersionId}": {
+ "get": {
+ "tags": [
+ "Resource"
+ ],
+ "summary": "Get External content details of a resource by ResourceVersionId.",
+ "parameters": [
+ {
+ "name": "resourceVersionId",
+ "in": "path",
+ "description": "The resourceVersionIdSystem.Int32.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int32"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK"
+ }
+ }
+ }
+ },
"/Resource/GetWeblinkDetails/{resourceVersionId}": {
"get": {
"tags": [
@@ -3682,6 +3707,31 @@
}
}
},
+ "/Resource/GetResourceVersion/{resourceVersionId}": {
+ "get": {
+ "tags": [
+ "Resource"
+ ],
+ "summary": "Get specific ResourceVersion by Id.",
+ "parameters": [
+ {
+ "name": "resourceVersionId",
+ "in": "path",
+ "description": "The resourceVersionIdSystem.Int32.",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int32"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK"
+ }
+ }
+ }
+ },
"/Resource/GetResourceVersionViewModel/{resourceVersionId}": {
"get": {
"tags": [