Skip to content

Commit 0355dc3

Browse files
committed
fix exception on getting formatStr, also put that logic in an extension method to be consistent
1 parent bb3b872 commit 0355dc3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

TASVideos/Extensions/ViewDataDictionaryExtensions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public static void SetNavigation(this ViewDataDictionary viewData, int id, strin
5151
viewData["NavigationFmtStr"] = fmtStr;
5252
}
5353

54+
public static string GetNavigationFormatStr(this ViewDataDictionary viewData)
55+
=> viewData["NavigationFmtStr"] as string ?? "";
56+
5457
public static string ActivePageClass(this ViewDataDictionary viewData, string page)
5558
{
5659
var activePage = viewData["ActivePage"] as string;

TASVideos/Pages/Shared/_Layout.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
var heading = ViewData.GetHeading();
9090
int? prev = null;
9191
int? next = null;
92-
string? fmtStr = ViewData["NavigationFmtStr"] as string;
92+
string fmtStr = ViewData.GetNavigationFormatStr();
9393
if (User.Has(PermissionTo.CatalogMovies))
9494
{
9595
var id = ViewData.Int("NavigationId");

0 commit comments

Comments
 (0)