I'm setting a Menu with Sub-menu
display Sub-categories
, in database I created a column isSelected
with Boolean data type. If only Sub-categories
is isSelected == true
, it will be display on main page. I'm wondering how to setting Sub-categories
with isSelected == true
display on Menu
on the header
.
IQueryable<ProductSubcategory> list = null;
if (Id == null)
{
list = BikesDB.ProductSubcategories;
}
else
{
int id = Id.Value;
list = BikesDB.ProductSubcategories.Where
(m => m.ProductSubcategoryID == id && m.NameofBike == Name);
}
var bikes = list.Where(m => m.isSelected == true)
.AsEnumerable().Select
(p => new Bike { Id = p.ProductSubcategoryID, Name = p.NameofBike });
var viewModel = new CategoriesIndexViewModel
{
NumberOfModel = bikes.Count(),
NameofBike = bikes.Select(b=>b.Name).ToList(),
Bikes = bikes.ToList()
};
return this.View(viewModel);
Now I just hard-code three sub-menus in HTML
:
<li>
<a href="@Url.Content("~/Bike/")">Home</a>
<ul>
<li>
<a href="@Url.Content("~/Bike/Categories/1?name=Mountain Bikes&class=image")">Mountain Bikes</a>
</li>
<li>
<a href="@Url.Content("~/Bike/Categories/2?name=Road Bikes&class=image")">Road Bikes</a>
</li>
<li>
<a href="@Url.Content("~/Bike/Categories/3?name=Touring Bikes&class=image")">Touring Bikes</a>
</li>
</ul>
How to fix it dynamically based on Sub-categories
display on main page ???