Skip to content

Commit

Permalink
Refactored to a better readability and performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Farshad DASHTI authored and Farshad DASHTI committed Sep 10, 2024
1 parent 3a5d09a commit f787975
Showing 1 changed file with 11 additions and 7 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,15 +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)
{
if (userState != null)
userState.TrustUkPrn = model.TrustUkPrn;
await _cachedService.StoreData(GetUserName(), 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 f787975

Please sign in to comment.