コード例 #1
0
        public PlayerCupStats UpdatePlayerCupStats(PlayerFixture playerFixture, Cup cup, Season season)
        {
            PlayerCupStats playerCupStats;

            // Get all PlayerFixture records for specified season
            List<PlayerFixture> playerFixturesForCup = statsReportingService.GetPlayerFixtureStatsForCupAndSeason(playerFixture.Player.Id, cup.Id, season.Id).ToList();

            // Total stats
            int totalPoints = playerFixturesForCup.Sum(pf => pf.PointsScored);
            int totalFouls = playerFixturesForCup.Sum(pf => pf.Fouls);
            int mvpAwards = playerFixturesForCup.Count(pf => pf.IsMvp == "Y");

            // Find existing record
            playerCupStats = statsReportingService.GetPlayerCupStats(playerFixture.Player.Id, cup.Id, season.Id);

            // If doesn't exist, create new
            if (playerCupStats == null)
                playerCupStats = new PlayerCupStats(playerFixture.Player, cup, season, totalPoints, totalFouls, playerFixturesForCup.Count, mvpAwards);
            else
            {
                // Update values
                playerCupStats.UpdateStats(totalPoints, totalFouls, playerFixturesForCup.Count, mvpAwards);
            }

            // Save
            matchResultRepository.SavePlayerCupStats(playerCupStats);

            return playerCupStats;
        }
コード例 #2
0
 public PlayerCupStats SavePlayerCupStats(PlayerCupStats playerCupStats)
 {
     playerCupStatsRepository.InsertOrUpdate(playerCupStats);
     return playerCupStats;
 }