0
I have the following scenario: I have to move on to a view
data from different tables (similar data, but without any relation), until then I got good. I created a class (viewmodel) that receives the data, in the Controller
feed her when I return to the view, and on view
give a foreach on each property and within that foreach I review the PartialView
respective. So far so good.
However, I intend to "mix" these partialView
, and not show first the data of a property and after that all end, go to another.
How would you display this in a "random" way? Or rather, what is the logic for displaying something "random"? Is it some for loop?
For greater understanding, follows the ViewModel
, Controller
and View
:
Viewmodel
public class VideosManuaisIndex
{
public IEnumerable<Video> Videos { get; set; }
public IEnumerable<Manual> Manuais { get; set; }
}
Controller
public ActionResult Index()
{
return View(new VideosManuaisIndex
{
Videos = db.Video.ToList().OrderBy(v => v.sistema),
Manuais = db.Manual.ToList().OrderBy(m => m.sistema)
});
}
View
<div class="vid-lista">
@foreach (var manual in Model.Manuais)
{
@Html.Partial("_Manual", manual);
}
@foreach (var video in Model.Videos)
{
@Html.Partial("_Video", video)
}
</div>