我想穿着类别进入视野。我该怎么做? ParentID 1是主要类别。
数据库
http://i.stack.imgur.com/2ePTR.png
菜单
http://i.stack.imgur.com/kPSPX.png
如何在视野中修饰交易类别?
的HomeController
public class HomeController : Controller
{
private readonly ISliderRepository _sliderRepository;
private readonly IRefRepository _refRepository;
public HomeController(ISliderRepository sliderRepository, IRefRepository refRepository)
{
_sliderRepository = sliderRepository;
_refRepository = refRepository;
}
public ActionResult Index()
{
var Model = new HomePageView
{
Slider = _sliderRepository.GetAll().ToList(),
Ref = _refRepository.GetAll().ToList()
};
List<HomePageView> newList = new List<HomePageView>();
newList.Add(Model);
ViewBag.SliderLinkActive = "active";
ViewBag.SliderLinkNoActive = "";
return View(newList);
}
}
查看
@model System.Collections.Generic.IEnumerable<Web.ViewModel.HomePageView>
<nav class="header__navigation collapse navbar-toggleable-md" id="structurepress-main-navigation" aria-label="Main Menu">
<a class="home-icon" href="index.html">
<i class="fa fa-home"></i>
</a>
<ul class="main-navigation js-main-nav" role="menubar">
<li class="menu-item-has-children current-menu-item">
<a href="index.html">Home</a>
<ul class="sub-menu">
<li>
<a href="index.html">Slideshow</a>
</li>
<li>
<a href="index_static.html">Static image</a>
</li>
<li>
<a href="index_video.html">Video background</a>
</li>
</ul>
</li>
<li>
<a href="about.html">About</a>
</li>
<li class="menu-item-has-children">
<a href="services.html">Services</a>
<ul class="sub-menu">
<li>
<a href="construction-consultant.html">Construction Consultant</a>
</li>
<li>
<a href="green-building.html">Green Building</a>
</li>
<li>
<a href="laminate-flooring.html">Laminate Flooring</a>
</li>
<li>
<a href="house-renovation.html">House Renovation</a>
</li>
<li>
<a href="general-contracting.html">General Contracting</a>
</li>
<li>
<a href="metal-roofing.html">Metal Roofing</a>
</li>
</ul>
</li>
<li>
<a href="projects.html">Projects</a>
</li>
<li>
<a href="news.html">News</a>
</li>
<li>
<a href="contact.html">Contact</a>
</li>
</ul>
</nav>
主页
namespace Web.ViewModel
{
public class HomePageView
{
public List<Category> Category { get; set; }
public List<Slider> Slider { get; set; }
public List<SliderImage> SliderImage { get; set; }
public List<Ref> Ref { get; set; }
public List<RefImage> RefImage { get; set; }
public List<Contact> Contact { get; set; }
public List<Setting> Setting { get; set; }
}
}