diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IUserGroupService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IUserGroupService.cs
new file mode 100644
index 000000000..bd2f4e920
--- /dev/null
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IUserGroupService.cs
@@ -0,0 +1,16 @@
+namespace LearningHub.Nhs.OpenApi.Services.Interface.Services
+{
+ using System.Threading.Tasks;
+
+ ///
+ /// The UserGroupService interface.
+ ///
+ public interface IUserGroupService
+ {
+ ///
+ /// The GetRoleUserGroupDetailAsync.
+ ///
+ /// The .
+ Task UserHasCatalogueContributionPermission(int userId);
+ }
+}
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs
index 76e66812f..e0bef0a1d 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs
@@ -12,14 +12,17 @@
public class NavigationPermissionService : INavigationPermissionService
{
private readonly IResourceService resourceService;
+ private readonly IUserGroupService userGroupService;
///
/// Initializes a new instance of the class.
///
/// Resource service.
- public NavigationPermissionService(IResourceService resourceService)
+ /// userGroup service.
+ public NavigationPermissionService(IResourceService resourceService, IUserGroupService userGroupService)
{
this.resourceService = resourceService;
+ this.userGroupService = userGroupService;
}
///
@@ -53,7 +56,7 @@ public async Task GetNavigationModelAsync(IPrincipal user, bool
}
else if (user.IsInRole("BlueUser"))
{
- return AuthenticatedBlueUser(controllerName);
+ return await AuthenticatedBlueUser(controllerName, user.Identity.GetCurrentUserId());
}
else
{
@@ -114,12 +117,13 @@ private NavigationModel AuthenticatedAdministrator(string controllerName)
/// The AuthenticatedBlueUser.
///
/// The controller name.
+ /// The userId.
/// The .
- private NavigationModel AuthenticatedBlueUser(string controllerName)
+ private async Task AuthenticatedBlueUser(string controllerName, int userId)
{
return new NavigationModel()
{
- ShowMyContributions = true,
+ ShowMyContributions = await this.userGroupService.UserHasCatalogueContributionPermission(userId),
ShowMyLearning = true,
ShowMyBookmarks = true,
ShowSearch = controllerName != "search" && controllerName != string.Empty,
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/UserGroupService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/UserGroupService.cs
new file mode 100644
index 000000000..205494eca
--- /dev/null
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/UserGroupService.cs
@@ -0,0 +1,45 @@
+namespace LearningHub.Nhs.OpenApi.Services.Services
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using LearningHub.Nhs.Caching;
+ using LearningHub.Nhs.Models.Enums;
+ using LearningHub.Nhs.Models.Extensions;
+ using LearningHub.Nhs.Models.User;
+ using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories;
+ using LearningHub.Nhs.OpenApi.Services.Interface.Services;
+ using Microsoft.AspNetCore.Http;
+
+ ///
+ /// The user group service.
+ ///
+ public class UserGroupService : IUserGroupService
+ {
+
+ private readonly IRoleUserGroupRepository roleUserGroupRepository;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// roleUserGroupRepository.
+ public UserGroupService(IRoleUserGroupRepository roleUserGroupRepository)
+ {
+ this.roleUserGroupRepository = roleUserGroupRepository;
+ }
+
+
+ ///
+ public async Task UserHasCatalogueContributionPermission(int userId)
+ {
+ var userRoleGroups = await this.roleUserGroupRepository.GetRoleUserGroupViewModelsByUserId(userId);
+ if (userRoleGroups != null && userRoleGroups.Any(r => r.RoleEnum == RoleEnum.LocalAdmin || r.RoleEnum == RoleEnum.Editor))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ }
+}
diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs
index f620c101b..b92103a2f 100644
--- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs
+++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Startup.cs
@@ -31,6 +31,7 @@ public static void AddServices(this IServiceCollection services)
services.AddScoped();
services.AddScoped();
services.AddScoped();
+ services.AddScoped();
services.AddScoped();
services.AddScoped();