Skip to content

Commit

Permalink
EHD-1411: Reduce code in Core project: Inline GetRequestCookie code
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgriff committed Nov 4, 2024
1 parent f8a5891 commit 7d51f43
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 0 additions & 5 deletions GenderPayGap.Core/Extensions/AspNetCore/HttpContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public static void SetResponseCache(this Microsoft.AspNetCore.Http.HttpContext c
}
}

public static string GetRequestCookieValue(this Microsoft.AspNetCore.Http.HttpContext context, string key)
{
return context.Request.Cookies.ContainsKey(key) ? context.Request.Cookies[key] : null;
}

public static void SetResponseCookie(this Microsoft.AspNetCore.Http.HttpContext context,
string key,
string value,
Expand Down
8 changes: 3 additions & 5 deletions GenderPayGap.WebUI/Classes/Presentation/CompareViewService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ public CompareViewService(IHttpContextAccessor httpContext)

public void LoadComparedEmployersFromCookie()
{
string value = httpContext.GetRequestCookieValue(CookieNames.LastCompareQuery);

if (string.IsNullOrWhiteSpace(value))
if (!httpContext.Request.Cookies.TryGetValue(CookieNames.LastCompareQuery, out string cookieValue))
{
return;
cookieValue = "";
}

string[] employerIds = value.SplitI(",");
string[] employerIds = cookieValue.SplitI(",");

ComparedEmployers.Clear();
foreach (string employerId in employerIds)
Expand Down

0 comments on commit 7d51f43

Please sign in to comment.