ViewBag.WinLossRatio =
new WinLossRatioVM
{
Wins = ctx.Games.Where(p => p.IsWin == true).Count(),
Total = ctx.Games.Count(),
Percent = ctx.Games.Where(p => p.IsWin == true).Count() / ctx.Games.Count() * 100
};
In the above code, I simply try to get the ratio of wins to the total number of games played. The first two properties, Wins and Total return five and eleven, respectively. The last property only returns as zero. The model is simply as follows:
public class WinLossRatioVM
{
public int Wins { get; set; }
public int Total { get; set; }
public int Percent { get; set; }
}
Why does Percent return zero?