예제 #1
0
        public void Update(TeamStatWorldCup teamStatWorldCup)
        {
            var teamStatWorldCupModified = _mapper.Map <TeamStatsWorldCup>(teamStatWorldCup);

            _ctx.TeamStatsWorldCup.Attach(teamStatWorldCupModified);
            _ctx.Entry(teamStatWorldCupModified).State = EntityState.Modified;
        }
예제 #2
0
        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);
        }
예제 #3
0
 public async Task Add(TeamStatWorldCup teamStatWorldCup)
 {
     var teamStatWorldCupToAdd = _mapper.Map <TeamStatsWorldCup>(teamStatWorldCup);
     await _ctx.TeamStatsWorldCup.AddAsync(teamStatWorldCupToAdd);
 }
예제 #4
0
 public async Task Update(TeamStatWorldCup teamStat)
 {
     _teamStatWorldCupRepository.Update(teamStat);
     await _teamStatWorldCupRepository.SaveChanges();
 }
예제 #5
0
        public async Task Add(TeamStatWorldCup teamStat)
        {
            await _teamStatWorldCupRepository.Add(teamStat);

            await _teamStatWorldCupRepository.SaveChanges();
        }