public TeamInfoStatisticViewModel(TeamStatisticsViewModel model, TeamDb team) { this.LeagueName = team.Name; this.Id = model.Id; this.GamesCount = model.GamesCount; this.Wins = model.Wins; this.Loses = model.Loses; this.Draws = model.Draws; this.Scores = model.Scores; this.Missed = model.Missed; this.Points = model.Points; }
// GET: Statistics public ActionResult Index() { var model = new TeamsPlayersStatisticsViewModel(); model.Teams = new List <TeamStatisticsViewModel>(); model.Players = new List <PlayerStatisticsViewModel>(); var teams = teamRepository.GetAll(); teams.ForEach(t => { int counterWins = 0; int counterDraws = 0; int counterLosses = 0; var team = new TeamStatisticsViewModel(); team.Name = t.Name; t.Matches.Where(m => m.Status == "Finished").ToList().ForEach(m => { if (m.HostTeamResult > m.GuestTeamResult) { counterWins++; } else if (m.HostTeamResult < m.GuestTeamResult) { counterLosses++; } else { counterDraws++; } }); t.Matches1.Where(m => m.Status == "Finished").ToList().ForEach(m => { if (m.HostTeamResult < m.GuestTeamResult) { counterWins++; } else if (m.HostTeamResult > m.GuestTeamResult) { counterLosses++; } else { counterDraws++; } }); team.NumberOfWins = counterWins; team.NumberOfDraws = counterDraws; team.NumberOfLosses = counterLosses; model.Teams.Add(team); }); var players = playerRepository.GetAll(); players.ToList().ForEach(p => { int counterMatches = 0; int counterGoals = 0; var player = new PlayerStatisticsViewModel(); player.Name = p.Name; player.TeamName = p.Team.Name; p.PlayerOnMatches.ToList().ForEach(pom => { if (pom.Match.Status.Equals("Finished")) { counterMatches++; counterGoals += pom.Score; } }); player.Matches = counterMatches; player.Goals = counterGoals; model.Players.Add(player); }); return(View(model)); }