Skip to content

Commit

Permalink
Merge pull request #1365 from DFE-Digital/hotfix/179198-fix-caching-i…
Browse files Browse the repository at this point in the history
…ssue

Fixed an issue where when the cache is expired the page throws an exception
  • Loading branch information
FrostyApeOne authored Sep 10, 2024
2 parents 386d72b + f787975 commit c7c7b33
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ConcernsCaseWork.Models;
using ConcernsCaseWork.Models.CaseActions;
using ConcernsCaseWork.Pages.Base;
using ConcernsCaseWork.Redis.Models;
using ConcernsCaseWork.Redis.Users;
using ConcernsCaseWork.Service.Permissions;
using ConcernsCaseWork.Services.Actions;
Expand Down Expand Up @@ -245,14 +246,18 @@ private async Task<bool> IsCaseDeletable(long caseId)

private async Task UpdateCacheService(CaseModel model)
{
var userState = await _cachedService.GetData(GetUserName());
var trustUkPrn = userState.TrustUkPrn;
if (trustUkPrn == null)
var userName = GetUserName();

var userState = await _cachedService.GetData(userName);

if (userState?.TrustUkPrn != null)
{
userState.TrustUkPrn = model.TrustUkPrn;
await _cachedService.StoreData(userState.UserName, userState);
return;
}


if (userState != null)
userState.TrustUkPrn = model.TrustUkPrn;
await _cachedService.StoreData(userName, userState);
}

public async Task<IActionResult> OnGetPaginatedActiveCases(string trustUkPrn, int pageNumber)
Expand Down

0 comments on commit c7c7b33

Please sign in to comment.