0

I wont to display other results according to one row:

Country>>League
HomeTeam AwayTeam Result

Italy>>Seria A
Juventus Inter [1-0]
Inter Barcelona[2-0]
Albania>>Kategoria Superiore
Tirana-Kukes [2-1]

What i have done till now displays this:
Italy>>Seria A
Juventus Inter [1-0]
Italy>>Seria A
Inter Barcelona[2-0]
Albania>>Kategoria Superiore
Tirana-Kukes [2-1]

 @foreach (var item in Model)
                {
                    <tr> <td>
                            @Html.DisplayFor(modelItem => item.Time)
                        </td> <td>
                            @Html.DisplayFor(modelItem => item.Country)
                        </td> <td>
                            @Html.DisplayFor(modelItem => item.League)
                        </td> <td>
                            @Html.DisplayFor(modelItem => item.Home)
                        </td> <td>
                            @Html.DisplayFor(modelItem => item.Away)
                        </td> <td>

                            @Html.ActionLink(item.Prediction, "IndexDetails", new { id = item.TeamId })
                        </td> <td>
                            @Html.DisplayFor(modelItem => item.Odds)
                        </td> <td>
                        ?-?
                        </td> </tr>
                }
            </table>

Edited by Stat_1

1
Contributor
1
Reply
24
Views
6 Months
Discussion Span
Last Post by Stat_1
0

i solve it :
this is the controller:

   public ActionResult Today()
        {
            List<TeamDetails> TeamList = new List<TeamDetails>();
            using (StattipsEntities dc = new StattipsEntities())
            {
                var v = (from a in dc.Countries
                         join b in dc.Matches on a.MatchId equals b.MatchId
                         select new
                         {
                             a.CountryId,
                             a.CountryName,
                             b.MatchId,
                             b.Date,
                             b.Time,
                             b.League,
                             b.HomeTeam,
                             b.AwayTeam,
                             b.Result,
                             b.Chances,
                             b.C1,
                             b.x,
                             b.C2,
                             b.g,
                             b.o,
                             b.u,
                             b.gg
                         });
                foreach (var i in v)
                {
                    TeamList.Add(new TeamDetails
                    {
                        CountryId = i.CountryId,
                        CountryName = i.CountryName,
                        MatchId = i.MatchId,
                        League = i.League,
                        HomeTeam = i.HomeTeam,
                        AwayTeam = i.AwayTeam,
                        Result = i.Result,
                        Chances = i.Chances,
                        C1 = i.C1,
                        x = i.x,
                        C2 = i.C2,
                        g = i.g,
                        o = i.o,
                        u = i.u,
                        gg = i.gg
                    });
                }
            }

            return View(TeamList);
        }

And this is the view:

@{
        foreach (var item in Model.Select(a => a.CountryName).Distinct())
        {
            <table class="table table-bordered table-striped" style="font-size:12px;text-align:center;vertical-align:middle;width:100%">

                <tr style="text-align:center;font-size:12px;background-color:#3b4148;color:white">
                    <th colspan="5" style="padding-left:10px"><b>@item &raquo;</b></th>
                    <th style="text-align:center;font-size:12px">Best</th>
                    <th style="text-align:center;font-size:12px">1</th>
                    <th style="text-align:center;font-size:12px">X</th>
                    <th style="text-align:center;font-size:12px">2</th>
                    <th style="text-align:center;font-size:12px">G</th>
                    <th style="text-align:center;font-size:12px">O</th>
                    <th style="text-align:center;font-size:12px">U</th>
                    <th style="text-align:center;font-size:12px">GG</th>
                </tr>
                @foreach (var i in Model.Where(a => a.CountryName.Equals(@item)))
                {
                 <tr style="font-size:12px;">
                        <td style="font-size:18px;text-align:center;vertical-align:middle;"><a href=""><i class="glyphicon glyphicon-star" style="color:#f05514"></i></a></td>
                        <td style="text-align:center;vertical-align:middle;">@Html.DisplayFor(modelItem => i.Date)<br />23:00</td>
                        <td width="30%" colspan="2" style="text-align:center;vertical-align:middle;">@Html.DisplayFor(modelItem => i.HomeTeam)<br />@Html.DisplayFor(modelItem => i.AwayTeam)</td>
                        <td style="font-size:13px;text-align:center;vertical-align:middle;">@Html.ActionLink(i.Result, "Details", new { id = i.MatchId })<br /><p style="font-size:11px;color:#3b4148">(0-0)</p></td>
                        @*<td style="text-align:center;vertical-align:middle;font-size:13px"><a href="/Home/Details">1-0</a></td>*@
                        <td style="text-align:center;vertical-align:middle;">1<br />@Html.DisplayFor(modelItem => i.Chances)%</td>
                        <td>@Html.DisplayFor(modelItem => i.C1)<br />39%</td>
                        <td>@Html.DisplayFor(modelItem => i.x)<br />60%</td>
                        <td>@Html.DisplayFor(modelItem => i.C2)<br />40%</td>
                        <td>@Html.DisplayFor(modelItem => i.g)<br />37%</td>
                        <td>@Html.DisplayFor(modelItem => i.o)<br />31%</td>
                        <td>@Html.DisplayFor(modelItem => i.u)<br />60%</td>
                        <td>@Html.DisplayFor(modelItem => i.gg)<br />50%</td>
                    </tr>
                }
            </table>
        }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.