From fe196ca2564911bff88ac8fac96ab332489ad77e Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 22 Sep 2021 22:59:14 +1000 Subject: [PATCH] 10.2.2.1 Helping the Controller Select a View; Listing 10-5 Updating the Menu Action Method in the NavController.cs File --- SportsStore/SportsStore.WebUI/Controllers/NavController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SportsStore/SportsStore.WebUI/Controllers/NavController.cs b/SportsStore/SportsStore.WebUI/Controllers/NavController.cs index b201885..66d2d6c 100644 --- a/SportsStore/SportsStore.WebUI/Controllers/NavController.cs +++ b/SportsStore/SportsStore.WebUI/Controllers/NavController.cs @@ -16,7 +16,8 @@ namespace SportsStore.WebUI.Controllers repository = repo; } - public PartialViewResult Menu(string category = null) + public PartialViewResult Menu(string category = null, + bool horizontalLayout = false) { ViewBag.SelectedCategory = category; @@ -25,7 +26,8 @@ namespace SportsStore.WebUI.Controllers .Distinct() .OrderBy(x => x); - return PartialView(categories); + string viewName = horizontalLayout ? "MenuHorizontal" : "Menu"; + return PartialView(viewName, categories); } } } \ No newline at end of file