Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions LearningHub.Nhs.WebUI/Controllers/CatalogueController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ public async Task<IActionResult> IndexAsync(string reference, string tab, int? n
CatalogueAccessRequestViewModel catalogueAccessRequest = null;
if (this.ViewBag.UserAuthenticated)
{
var cacheKey = $"{this.CurrentUserId}:AllRolesWithPermissions";
await this.cacheService.RemoveAsync(cacheKey);
userGroups = await this.userGroupService.GetRoleUserGroupDetailAsync();
catalogueAccessRequest = await this.catalogueService.GetLatestCatalogueAccessRequestAsync(catalogue.NodeId);
}
Expand Down
4 changes: 2 additions & 2 deletions LearningHub.Nhs.WebUI/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async Task<IActionResult> Index(int resourceReferenceId, bool? acceptSens

var resource = await this.resourceService.GetItemByIdAsync(resourceReferenceId);

if (resource.Id == 0 || (resource.Catalogue != null && resource.Catalogue.Hidden))
if ((resource == null && resource.Id == 0) || (resource.Catalogue != null && resource.Catalogue.Hidden))
{
this.ViewBag.SupportFormUrl = this.Settings.SupportUrls.SupportForm;
return this.View("Unavailable");
Expand All @@ -147,7 +147,7 @@ public async Task<IActionResult> Index(int resourceReferenceId, bool? acceptSens
var hasCatalogueAccess = false;
if (resource.Catalogue.RestrictedAccess && this.User.Identity.IsAuthenticated)
{
var userGroups = await this.userGroupService.GetRoleUserGroupDetailForUserAsync(this.CurrentUserId);
var userGroups = await this.userGroupService.GetRoleUserGroupDetailAsync();

hasCatalogueAccess = userGroups.Any(x => x.CatalogueNodeId == resource.Catalogue.NodeId &&
(x.RoleEnum == RoleEnum.LocalAdmin || x.RoleEnum == RoleEnum.Editor || x.RoleEnum == RoleEnum.Reader)) || this.User.IsInRole("Administrator");
Expand Down
25 changes: 14 additions & 11 deletions LearningHub.Nhs.WebUI/Services/ResourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,21 @@ public async Task<ResourceItemViewModel> GetItemByIdAsync(int id)

resourceItem = JsonConvert.DeserializeObject<ResourceItemViewModel>(result);

resourceItem.LicenseUrl = this.settings.ResourceLicenseUrl;

// if resource type is video, add azure media content protection authentication token
if (resourceItem.ResourceTypeEnum == ResourceTypeEnum.Video && resourceItem.VideoDetails != null && resourceItem.VideoDetails.ResourceAzureMediaAsset != null && !string.IsNullOrEmpty(resourceItem.VideoDetails.ResourceAzureMediaAsset.FilePath))
{
resourceItem.VideoDetails.ResourceAzureMediaAsset.AuthenticationToken = await this.azureMediaService.GetContentAuthenticationTokenAsync(resourceItem.VideoDetails.ResourceAzureMediaAsset.FilePath);
}

// if resource type is audio, add azure media content protection authentication token
if (resourceItem.ResourceTypeEnum == ResourceTypeEnum.Audio && resourceItem.AudioDetails != null && resourceItem.AudioDetails.ResourceAzureMediaAsset != null && !string.IsNullOrEmpty(resourceItem.AudioDetails.ResourceAzureMediaAsset.FilePath))
if (resourceItem != null)
{
resourceItem.AudioDetails.ResourceAzureMediaAsset.AuthenticationToken = await this.azureMediaService.GetContentAuthenticationTokenAsync(resourceItem.AudioDetails.ResourceAzureMediaAsset.FilePath);
resourceItem.LicenseUrl = this.settings.ResourceLicenseUrl;

// if resource type is video, add azure media content protection authentication token
if (resourceItem.ResourceTypeEnum == ResourceTypeEnum.Video && resourceItem.VideoDetails != null && resourceItem.VideoDetails.ResourceAzureMediaAsset != null && !string.IsNullOrEmpty(resourceItem.VideoDetails.ResourceAzureMediaAsset.FilePath))
{
resourceItem.VideoDetails.ResourceAzureMediaAsset.AuthenticationToken = await this.azureMediaService.GetContentAuthenticationTokenAsync(resourceItem.VideoDetails.ResourceAzureMediaAsset.FilePath);
}

// if resource type is audio, add azure media content protection authentication token
if (resourceItem.ResourceTypeEnum == ResourceTypeEnum.Audio && resourceItem.AudioDetails != null && resourceItem.AudioDetails.ResourceAzureMediaAsset != null && !string.IsNullOrEmpty(resourceItem.AudioDetails.ResourceAzureMediaAsset.FilePath))
{
resourceItem.AudioDetails.ResourceAzureMediaAsset.AuthenticationToken = await this.azureMediaService.GetContentAuthenticationTokenAsync(resourceItem.AudioDetails.ResourceAzureMediaAsset.FilePath);
}
}
}
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized
Expand Down
4 changes: 2 additions & 2 deletions WebAPI/LearningHub.Nhs.API/Controllers/HierarchyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public HierarchyController(IUserService userService, IHierarchyService hierarchy
/// <returns>The node details.</returns>
[HttpGet]
[Route("GetNodeDetails/{nodeId}")]
public NodeViewModel GetNodeDetails(int nodeId)
public async Task<NodeViewModel> GetNodeDetails(int nodeId)
{
var retVal = this.hierarchyService.GetNodeDetails(nodeId);
var retVal = await this.hierarchyService.GetNodeDetails(nodeId);

return retVal;
}
Expand Down
12 changes: 6 additions & 6 deletions WebAPI/LearningHub.Nhs.API/Controllers/UserGroupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public async Task<IActionResult> GetUserGroupAdminDetailById(int id)
/// <returns>The <see cref="Task"/>.</returns>
[HttpGet]
[Route("GetUserGroupAdminRoleDetailById/{id}")]
public IActionResult GetUserGroupAdminRoleDetailById(int id)
public async Task<IActionResult> GetUserGroupAdminRoleDetailById(int id)
{
var retVal = this.userGroupService.GetUserGroupRoleDetailByUserGroupId(id);
var retVal = await this.userGroupService.GetUserGroupRoleDetailByUserGroupId(id);

return this.Ok(retVal);
}
Expand All @@ -75,9 +75,9 @@ public IActionResult GetUserGroupAdminRoleDetailById(int id)
/// <returns>The <see cref="Task"/>.</returns>
[HttpGet]
[Route("GetUserGroupRoleDetailByUserId/{userId}")]
public IActionResult GetRoleUserGroupDetailByUserId(int userId)
public async Task<IActionResult> GetRoleUserGroupDetailByUserId(int userId)
{
var retVal = this.userGroupService.GetRoleUserGroupDetailByUserId(userId);
var retVal = await this.userGroupService.GetRoleUserGroupDetailByUserId(userId);

return this.Ok(retVal);
}
Expand All @@ -88,9 +88,9 @@ public IActionResult GetRoleUserGroupDetailByUserId(int userId)
/// <returns>The <see cref="Task"/>.</returns>
[HttpGet]
[Route("GetUserGroupRoleDetail")]
public IActionResult GetRoleUserGroupDetail()
public async Task<IActionResult> GetRoleUserGroupDetail()
{
var retVal = this.userGroupService.GetRoleUserGroupDetailByUserId(this.CurrentUserId);
var retVal = await this.userGroupService.GetRoleUserGroupDetailByUserId(this.CurrentUserId);

return this.Ok(retVal);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
-- 11-05-2023 RS Removed Description and AuthoredBy as no longer required for screen.
-- 15-05-2023 RS Added AuthoredBy back in following design decision change.
-- 23-06-2023 RS Removed AverageRating and RatingCount as not required from this proc. That data comes separately from RatingService.
-- 05-06-2023 SA Modified the sp to fix the sql timeout issues.
-------------------------------------------------------------------------------
CREATE PROCEDURE [hierarchy].[GetNodeContentsForCatalogueBrowse]
(
Expand All @@ -23,6 +24,14 @@ AS

BEGIN

IF @NodeId IS NULL
BEGIN
RAISERROR('NodeId cannot be null', 16, 1)
RETURN
END

;WITH CTENode AS(SELECT DISTINCT NodeId FROM hierarchy.NodeResourceLookup WHERE Deleted = 0)

SELECT
ROW_NUMBER() OVER(ORDER BY DisplayOrder) AS Id,
[Name],
Expand Down Expand Up @@ -64,7 +73,7 @@ BEGIN
INNER JOIN
hierarchy.FolderNodeVersion fnv ON fnv.NodeVersionId = nv.Id
INNER JOIN -- Exclude folders with no published resources.
(SELECT DISTINCT NodeId FROM hierarchy.NodeResourceLookup WHERE Deleted = 0) nrl ON cn.Id = nrl.NodeId
CTENode nrl ON cn.Id = nrl.NodeId
WHERE
nl.ParentNodeId = @NodeId
AND nl.Deleted = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-- Modification History
--
-- 21-01-2021 Killian Davies Initial Revision
-- 05-06-2023 SA Modified the sp to fix the sql timeout issues.
-------------------------------------------------------------------------------
CREATE PROCEDURE [hub].[RoleUserGroupGetByUserGroupId]
(
Expand All @@ -17,7 +18,6 @@ AS
BEGIN

SELECT
CAST([Sequence] AS int) AS [Key],
RoleUserGroupId,
UserGroupId,
UserGroupName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-- Modification History
--
-- 21-01-2021 Killian Davies Initial Revision
-- 05-06-2023 SA Modified the sp to fix the sql timeout issues.
-------------------------------------------------------------------------------
CREATE PROCEDURE [hub].[RoleUserGroupGetByUserId]
(
Expand All @@ -16,8 +17,7 @@ AS

BEGIN

SELECT
CAST([Sequence] AS int) AS [Key],
SELECT
RoleUserGroupId,
rug.UserGroupId,
UserGroupName,
Expand Down
Loading