0

The model item passed into the dictionary is of type 'System.String', but this dictionary requires a model item of type 'BetGuns.Web.Models.Home.VM_HotGames'.
How to fix this error

@foreach (var c in Model.Mathes)
        {

            decimal res1 = 0; decimal resx = 0; decimal res2 = 0; string proposal = string.Empty;
            string proposal2 = string.Empty;
            var pr = Model.Predictions.Find(i => i.MatchID == c.MatchID);
            var country = Model.CountriesList.Find(i => i.ID == c.CountryID);
            if (pr != null)
            {

                res1 = pr.Final_1;
                resx = pr.Final_X;
                res2 = pr.Final_2;
                var listProposal = FDBEngine.Models.Prediction.BestValueExtended(pr).Take(2).Select(i => i.Name).ToList();
                proposal = string.Join("  -  ", listProposal);
                proposal = listProposal.Any() ? listProposal.First() : string.Empty;
                proposal2 = listProposal.Count == 2 ? listProposal.Last() : string.Empty;

            }
            var dicHome = Model.TeamsMLDictrionary[c.HomeID];
            var homeMLName = dicHome[urlLanguage];
            var dicAway = Model.TeamsMLDictrionary[c.AwayID];
            var awayMLName = dicAway[urlLanguage];

            <tr style="font-size:11px;">

                <td style="text-align:center;"><a class="glyphicon glyphicon-remove removeFromCoupon pull-right myRed" style="cursor: pointer;" data-id="@c.MatchID"></a></td>

                <td class="text-center" style="text-align:center">
                    <p style="font-size:11px">
                        <img class="img-responsive" align="left" style="padding:1px" src='@Url.Action("GetImageBlob", "Home", new { id = country.MediaResourceFlagID , querystring = "w=15&h=15&mode=crop&scale=both" })' />
                        @country.Name : @BetGuns.Web.Controllers.HomeController.LeagueMLVal(c.LeagueID, urlLanguage)

                    </p>
                </td>
                <td style="text-align:center"><a href="@Url.Action("index", "versus", new { matchid = c.MatchID })" target="_blank" class="b">@homeMLName</a> - <a href="@Url.Action("index", "versus", new { matchid = c.MatchID })" target="_blank" class="b">@awayMLName</a></td>
                @if (Model.HasFullAccess)
            {
                    <td style="text-align:center">-</td>

                }
            </tr>

        }
    </tbody>

Edited by Reverend Jim: merged posts

2
Contributors
1
Reply
15
Views
1 Week
Discussion Span
Last Post by hericles
2

The error is quite clear. You're passing a string into a dictionary that is declared to accept BetGuns.Web.Models.Home.VM_HotGames.
You just need to look at the line causing the error and pass in a variable of the correct type.

Votes + Comments
Nice answer
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.