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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
<PackageReference Include="IdentityModel" Version="4.6.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.36" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Selenium.Axe" Version="4.0.19" />
Expand Down
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Include="IdentityModel" Version="4.6.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="linqtotwitter" Version="6.9.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.15.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace LearningHub.Nhs.OpenApi.Repositories.EntityFramework
using LearningHub.Nhs.Models.Hierarchy;
using LearningHub.Nhs.Models.Messaging;
using LearningHub.Nhs.Models.MyLearning;
using LearningHub.Nhs.Models.Notification;
using LearningHub.Nhs.Models.Resource;
using LearningHub.Nhs.Models.Resource.ResourceDisplay;
using LearningHub.Nhs.Models.User;
Expand Down Expand Up @@ -124,6 +125,11 @@ public LearningHubDbContextOptions Options
/// </summary>
public virtual DbSet<Notification> Notification { get; set; }

/// <summary>
/// Gets or sets the Notification Count.
/// </summary>
public virtual DbSet<NotificationCount> NotificationCount { get; set; }

/// <summary>
/// Gets or sets the user notification..
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="IdentityModel" Version="4.6.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace LearningHub.Nhs.OpenApi.Repositories.Repositories
{
using System;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Entities;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.OpenApi.Repositories.EntityFramework;
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;

/// <summary>
Expand Down Expand Up @@ -42,9 +44,23 @@ public async Task<UserNotification> GetByIdAsync(int id)
/// <returns>The <see cref="Task"/>.</returns>
public async Task<int> GetUserUnreadNotificationCountAsync(int userId)
{
return await GetActiveNotifications(userId, DateTimeOffset.Now)
.Where(n => !n.UserNotification.ReadOnDate.HasValue)
.CountAsync();
try
{
var param0 = new SqlParameter("@p0", SqlDbType.Int) { Value = userId };
var param1 = new SqlParameter("@p1", SqlDbType.Int) { Value = this.TimezoneOffsetManager.UserTimezoneOffset ?? (object)DBNull.Value };

var result = await this.DbContext
.NotificationCount
.FromSqlRaw("EXEC hub.GetActiveNotificationCount @p0, @p1", param0, param1)
.ToListAsync();

return result.FirstOrDefault()?.UserNotificationCount ?? 0;
}
catch (Exception ex)
{
// Optional: log ex
throw new Exception("Failed to get unread notification count: " + ex.Message);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ Task<AssessmentProgressViewModel> GetAssessmentProgress(
/// <returns>The <see cref="Task{LearningHubValidationResult}"/>.</returns>
Task<LearningHubValidationResult> CreateResourceVersionValidationResultAsync(ResourceVersionValidationResultViewModel validationResultViewModel);

/// <summary>
/// The get resource header view model async.
/// </summary>
/// <param name="resourceReferenceId">The resourceReferenceId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{ResourceHeaderViewModel}"/>.</returns>
Task<ResourceHeaderViewModel> GetResourceHeaderViewModelAsync(int resourceReferenceId);

/// <summary>
/// The set resource type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using AutoMapper;
using LearningHub.Nhs.Models.Dashboard;
using LearningHub.Nhs.Models.Provider;
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories.Hierarchy;
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories.Resources;
using LearningHub.Nhs.OpenApi.Services.Interface.Services;
Expand Down Expand Up @@ -56,7 +58,10 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearnings(str
{
foreach (var catalogue in catalogueList)
{
catalogue.Providers = await providerService.GetByCatalogueVersionIdAsync(catalogue.NodeVersionId);
if (!string.IsNullOrEmpty(catalogue.ProvidersJson))
{
catalogue.Providers = JsonSerializer.Deserialize<List<ProviderViewModel>>(catalogue.ProvidersJson);
}
}
}

Expand All @@ -65,7 +70,10 @@ public async Task<DashboardMyLearningResponseViewModel> GetMyAccessLearnings(str
{
foreach (var resource in resourceList)
{
resource.Providers = await providerService.GetByResourceVersionIdAsync(resource.ResourceVersionId);
if (!string.IsNullOrEmpty(resource.ProvidersJson))
{
resource.Providers = JsonSerializer.Deserialize<List<ProviderViewModel>>(resource.ProvidersJson);
}
}
}

Expand Down Expand Up @@ -95,7 +103,10 @@ public async Task<DashboardCatalogueResponseViewModel> GetCatalogues(string dash
var catalogueList = catalogues.Any() ? mapper.Map<List<DashboardCatalogueViewModel>>(catalogues) : new List<DashboardCatalogueViewModel>();
foreach (var catalogue in catalogueList)
{
catalogue.Providers = await providerService.GetByCatalogueVersionIdAsync(catalogue.NodeVersionId);
if (!string.IsNullOrEmpty(catalogue.ProvidersJson))
{
catalogue.Providers = JsonSerializer.Deserialize<List<ProviderViewModel>>(catalogue.ProvidersJson);
}
}

var response = new DashboardCatalogueResponseViewModel
Expand Down Expand Up @@ -123,7 +134,10 @@ public async Task<DashboardResourceResponseViewModel> GetResources(string dashbo

foreach (var resource in resourceList)
{
resource.Providers = await providerService.GetByResourceVersionIdAsync(resource.ResourceVersionId);
if (!string.IsNullOrEmpty(resource.ProvidersJson))
{
resource.Providers = JsonSerializer.Deserialize<List<ProviderViewModel>>(resource.ProvidersJson);
}
}

var response = new DashboardResourceResponseViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3587,6 +3587,23 @@ private LearningHubValidationResult ValidateRequestWithSourceResource(ResourceVe
return result;
}

/// <summary>
/// The get resource header view model async.
/// </summary>
/// <param name="resourceReferenceId">The resourceReferenceId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{ResourceHeaderViewModel}"/>.</returns>
public async Task<ResourceHeaderViewModel> GetResourceHeaderViewModelAsync(int resourceReferenceId)
{
var retVal = new ResourceHeaderViewModel();

var rv = await this.resourceVersionRepository.GetCurrentForResourceReferenceIdAsync(resourceReferenceId);

retVal.Id = resourceReferenceId;
retVal.Title = rv.Title;

return retVal;
}

private LearningHubValidationResult ValidateRequestWithSourceBlockCollection(BlockCollection sourceBlockCollection, DuplicateBlocksRequestModel requestModel)
{
var result = new LearningHubValidationResult(false, "Duplicate Blocks async: ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="NBuilder" Version="6.1.0" />
Expand Down
12 changes: 12 additions & 0 deletions OpenAPI/LearningHub.Nhs.OpenApi/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ public async Task<ActionResult> GetFileTypes()
return this.Ok(await this.fileTypeService.GetAllAsync());
}

/// <summary>
/// The get resource header view model async.
/// </summary>
/// <param name="resourceReferenceId">The resourceReferenceId<see cref="int"/>.</param>
/// <returns>The <see cref="Task{ActionResult}"/>.</returns>
[HttpGet]
[Route("GetResourceHeaderViewModelAsync/{resourceReferenceId}")]
public async Task<ActionResult> GetResourceHeaderViewModelAsync(int resourceReferenceId)
{
return this.Ok(await this.resourceService.GetResourceHeaderViewModelAsync(resourceReferenceId));
}

/// <summary>
/// The get file async.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ItemGroup>
<PackageReference Include="AspNetCore.Authentication.ApiKey" Version="8.0.1" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.18.3" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.18.3" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>

<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />

Expand Down
2 changes: 1 addition & 1 deletion WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Update="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
<PackageReference Include="FluentAssertions" Version="8.0.1" />
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
<Build Include="Stored Procedures\Activity\GetAssessmentActivityCompletionPercentage.sql" />
<Build Include="Tables\Hub\PasswordResetRequests.sql" />
<Build Include="Stored Procedures\External\ExternalSystemUserCreate.sql" />
<Build Include="Stored Procedures\Hub\GetActiveNotificationCount.sql" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\Pre-Deploy\Scripts\Card5766_AuthorTableChanges.PreDeployment.sql" />
Expand Down
Loading
Loading