10.2.2.1 Helping the Controller Select a View; Listing 10-5 Updating the Menu Action Method in the NavController.cs File

chap10
Jason Zhu 2021-09-22 22:59:14 +10:00
parent b03c3d3e77
commit fe196ca256
1 changed files with 4 additions and 2 deletions

View File

@ -16,7 +16,8 @@ namespace SportsStore.WebUI.Controllers
repository = repo; repository = repo;
} }
public PartialViewResult Menu(string category = null) public PartialViewResult Menu(string category = null,
bool horizontalLayout = false)
{ {
ViewBag.SelectedCategory = category; ViewBag.SelectedCategory = category;
@ -25,7 +26,8 @@ namespace SportsStore.WebUI.Controllers
.Distinct() .Distinct()
.OrderBy(x => x); .OrderBy(x => x);
return PartialView(categories); string viewName = horizontalLayout ? "MenuHorizontal" : "Menu";
return PartialView(viewName, categories);
} }
} }
} }