diff --git a/ConcernsCaseWork/ConcernsCaseWork/Pages/Case/Management/Index.cshtml.cs b/ConcernsCaseWork/ConcernsCaseWork/Pages/Case/Management/Index.cshtml.cs index 868e39a4c..de5ac8896 100644 --- a/ConcernsCaseWork/ConcernsCaseWork/Pages/Case/Management/Index.cshtml.cs +++ b/ConcernsCaseWork/ConcernsCaseWork/Pages/Case/Management/Index.cshtml.cs @@ -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; @@ -245,14 +246,18 @@ private async Task 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 OnGetPaginatedActiveCases(string trustUkPrn, int pageNumber)