public ActionResult Statistic() { List <Scorrer> topscorrer = new List <Scorrer>(); MatchReportRepository mdetailsrep = new MatchReportRepository(); var matchdet = mdetailsrep.GetAllMatchDetails(); PlayerRepository playerrep = new PlayerRepository(); var allplayers = playerrep.GetAllPlayers(); foreach (Player p in allplayers) { Scorrer scorrer = new Scorrer(); scorrer.Id = p.ID; scorrer.Name = p.LastName; scorrer.TeamName = p.Team.Name; scorrer.FName = p.Name; scorrer.Picture = p.Picture; int goals = 0; var players = matchdet.Where(g => g.ID == p.ID); foreach (MatchDetails pl in players) { if (pl.StatisticId == 7) { goals++; } } scorrer.Goals = goals; topscorrer.Add(scorrer); ViewData["Scorrer"] = topscorrer.Where(g => g.Goals > 0).OrderByDescending(k => k.Goals); } return(View()); }
public ActionResult PlayerStatistic(int Id) { List <Scorrer> topscorrer = new List <Scorrer>(); MatchReportRepository mdetailsrep = new MatchReportRepository(); var matchdet = mdetailsrep.GetAllMatchDetails(); PlayerRepository playerrep = new PlayerRepository(); var allplayers = playerrep.GetAllPlayers().Where(i => i.ID == Id); foreach (Player p in allplayers) { Scorrer scorrer = new Scorrer(); scorrer.Id = p.ID; scorrer.Name = p.LastName; scorrer.TeamName = p.Team.Name; scorrer.FName = p.Name; scorrer.Picture = p.Picture; int yellowCard = 0; int redCard = 0; int goals = 0; var players = matchdet.Where(g => g.ID == p.ID); // var statplayer = players.Where(i => i.ID == Id); foreach (MatchDetails pl in players) { if (pl.StatisticId == 7) { goals++; } if (pl.StatisticId == 8) { yellowCard++; } if (pl.StatisticId == 11) { redCard++; } } scorrer.Goals = goals; scorrer.YellowCard = yellowCard; scorrer.RedCard = redCard; topscorrer.Add(scorrer); ViewData["PlayerStat"] = topscorrer.OrderByDescending(k => k.Goals); } return(View()); }