How to do Table with two foreach close tr / tr Asp.Net MVC

0

I need to make a table that each line has the information as picture below

NoticethatinLot1toCitythedatadoesnotrepeateveryforeach,andonlyfromtheSpeciescolumndoesthedatarepeat,inthisrowtheforeachloops3timesandtheBatchcolumnsuptoCitysuffersarowspan

Belowcodethatisnotworkingaccordingly.

@modelGerenciamentoDeQuartos.Models.LoteViewModel@{ViewBag.Title="Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Adicionar Lote", "NewLot")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Lote.NumeroLote)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Proprietario.Nome)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Propriedade.Nome)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Cidade.Nome)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GetTipoGenero.Nome)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GetGenero.QuantidadeAnimais)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GetGenero.SequenciaInicial)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GetGenero.SequenciaFinal)
        </th>
    </tr>


    @foreach (var item in Model.LoteList)
    {
        var rowSpanTable = item.LoteGenero.Count() <= 1 ? 0 : item.LoteGenero.Count();
        var imprimeSomentePrimeiraLinha = false;

        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.NumeroLote)
            </td>

            @foreach (var itemLoteGenero in item.LoteGenero)
            {

                if (!imprimeSomentePrimeiraLinha)
                {
                    <td>
                        @Html.DisplayFor(modelItem => item.Proprietario.Nome)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Propriedade.Nome)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Propriedade.Cidade.Nome)
                    </td>
                }

                <td>
                    @Html.DisplayFor(modelItem => itemLoteGenero.Genero.TipoGenero.Nome)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => itemLoteGenero.Genero.QuantidadeAnimais)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => itemLoteGenero.Genero.SequenciaInicial)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => itemLoteGenero.Genero.SequenciaFinal)
                </td>

                imprimeSomentePrimeiraLinha = true;
            }

        </tr>
    }
</table>
    
asked by anonymous 15.04.2018 / 06:00

0 answers