I have the following scenario: I have to pass to a view
data of different tables (similar data, but without any relation), until then I got it good. I created a class (viewmodel) that receives the data, in the Controller
food it when I give the return to the view, and in view
I give a foreach in each property and inside that foreach I render the respective PartialView
. So far so good.
However, I intend to "mix" these partialView
, and do not first show the data of a property and after it all ends, go to another.
How would you display this in a "random" way? Or rather, what logic to display something "random"? Was it some for loop?
For more understanding, follow 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>