public void Update(TeamStatWorldCup teamStatWorldCup) { var teamStatWorldCupModified = _mapper.Map <TeamStatsWorldCup>(teamStatWorldCup); _ctx.TeamStatsWorldCup.Attach(teamStatWorldCupModified); _ctx.Entry(teamStatWorldCupModified).State = EntityState.Modified; }
private void CompleteTeamsStatWorldCup(Match match, ref TeamStatWorldCup team1Stat, ref TeamStatWorldCup team2Stat) { if (match.GoalsTeam1 > match.GoalsTeam2) { team1Stat.Wins++; team2Stat.Loses++; } else if (match.GoalsTeam2 > match.GoalsTeam1) { team2Stat.Wins++; team1Stat.Loses++; } else { team1Stat.Draws++; team2Stat.Draws++; } team1Stat.Points = team1Stat.Wins * 3 + team1Stat.Draws; team1Stat.GamesPlayed++; team1Stat.GoalsFavor += match.GoalsTeam1; team1Stat.GoalsAgainst += match.GoalsTeam2; team1Stat.GoalDifference = team1Stat.GoalsFavor - team1Stat.GoalsAgainst; team1Stat.Effectiveness = Math.Round(((decimal)team1Stat.Points / ((decimal)team1Stat.GamesPlayed * 3)) * 100, 2); team2Stat.Points = team2Stat.Wins * 3 + team2Stat.Draws; team2Stat.GamesPlayed++; team2Stat.GoalsFavor += match.GoalsTeam2; team2Stat.GoalsAgainst += match.GoalsTeam1; team2Stat.GoalDifference = team2Stat.GoalsFavor - team2Stat.GoalsAgainst; team2Stat.Effectiveness = Math.Round(((decimal)team2Stat.Points / ((decimal)team2Stat.GamesPlayed * 3)) * 100, 2); }
public async Task Add(TeamStatWorldCup teamStatWorldCup) { var teamStatWorldCupToAdd = _mapper.Map <TeamStatsWorldCup>(teamStatWorldCup); await _ctx.TeamStatsWorldCup.AddAsync(teamStatWorldCupToAdd); }
public async Task Update(TeamStatWorldCup teamStat) { _teamStatWorldCupRepository.Update(teamStat); await _teamStatWorldCupRepository.SaveChanges(); }
public async Task Add(TeamStatWorldCup teamStat) { await _teamStatWorldCupRepository.Add(teamStat); await _teamStatWorldCupRepository.SaveChanges(); }