foreach does not appear in Vista

2

I try to make this work but it does not show any errors or exceptions, it just does not appear in the view ...

@if (Model.Recetas != null)
{
    <div class="row">
        @foreach (Receta receta in Model.Recetas)
        {
            <div class="col-md-4">
                <div class="well">
                    <h4>@Html.ActionLink(receta.Titulo, "Receta", new { id = receta.Id, @class = "Recetas" })</h4>
                    <a href="@Url.Action("Receta", new { id = receta.Id })">
                        <img src="~/img/fotos/@receta.CoverImageFileName" alt="@receta.MostrarTexto" class="img-responsive" />
                    </a>
                </div>
            </div>
        }
    </div>
}
    
asked by CeciPeque 12.07.2018 в 19:49
source

1 answer

0

As I have already commented to you after correctly initializing the Model, this part of the view would look like this:

@if (Model.RepositorioRecetas != null)
    {
    <div class="row">
            @foreach (Receta receta in Model.RepositorioRecetas.GetRecetas())
            {
                <div class="col-md-4">
                    <div class="well">
                        <h4>@Html.ActionLink(receta.Titulo, "Receta", new { id = receta.Id, @class = "Recetas" })</h4>
                        <a href="@Url.Action("Receta", new {id = receta.Id})">
                            <img src="~/img/fotos/@receta.CoverImageFileName" alt="@receta.MostrarTexto" class="img-responsive" />
                        </a>
                    </div>
                </div>
            }
    </div>
}
    
answered by 13.07.2018 / 08:44
source