You must create a view model as follows:
public class FooViewModel
{
public IEnumerable<LinkModel> Links { get; set; }
public IEnumerable<AboutModel> Abouts { get; set; }
public IEnumerable<PortfolioModel> Portfolios { get; set; }
public IEnumerable<SkillModel> Skills { get; set; }
}
Then from your controller fill them in according to your requirements, for example:
public ActionResult Index()
{
var model = new FooViewModel();
model.Links = db.Links.ToList();
model.Abouts = db.Abouts.ToList();
model.Portfolios = db.Portfolios.ToList();
model.Skills = db.Skills.ToList();
return View(model);
}
Then change the model in your view to FooViewModel, and all your properties will be available there.
@model FooViewModel
<ul>
@foreach (var item in Model.Links)
{
<li>
@item
</li>
}
</ul>
<ul>
@foreach (var item in Model.Links)
{
<li>
@item
</li>
}
</ul>
// ....etc, obviously change the outputs as needed.
source
share