public PlayerCareerStatsDto(PlayerSeasonStats playerSeasonStats)
 {
     this.Year          = string.Format("{0}/{1}", playerSeasonStats.Season.StartYear, playerSeasonStats.Season.EndYear);
     this.Games         = playerSeasonStats.GamesPlayed.ToString();
     this.MvpAwards     = playerSeasonStats.MvpAwards.ToString();
     this.Fouls         = playerSeasonStats.TotalFouls.ToString();
     this.FoulsPerGame  = playerSeasonStats.FoulsPerGame.ToString("0.00");
     this.Points        = playerSeasonStats.TotalPoints.ToString();
     this.PointsPerGame = playerSeasonStats.PointsPerGame.ToString("0.00");
 }
        public void CanCreatePlayerSeasonStatsWithZeroGamesPlayed()
        {
            Season season = new Season(2009, 2010);
            Player player = new Player("Phil", "Hale");
            int totalPoints = -2;
            int totalFouls = 2;
            int gamesPlayed = 0;
            int mvpAwards = 5;

            PlayerSeasonStats stats = new PlayerSeasonStats(player, season, totalPoints, totalFouls, gamesPlayed, mvpAwards);

            Assert.IsNotNull(stats);
            Assert.That(stats.Season, Is.EqualTo(season));
            Assert.That(stats.Player, Is.EqualTo(player));
            Assert.That(stats.GamesPlayed, Is.EqualTo(0));
            Assert.That(stats.TotalPoints, Is.EqualTo(0));
            Assert.That(stats.PointsPerGame, Is.EqualTo(0));
            Assert.That(stats.TotalFouls, Is.EqualTo(0));
            Assert.That(stats.FoulsPerGame, Is.EqualTo(0));
            Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards));
        }
        protected PlayerSeasonStats AddPlayerSeasonStats(Player player, Season season, int totalPoints, int totalFouls, int gamesPlayed, int mvpAwards)
        {
            PlayerSeasonStats stats = new PlayerSeasonStats(player, season, totalPoints, totalFouls, gamesPlayed, mvpAwards);

            //statsRepository.SaveOrUpdatePlayerSeasonStats(stats);
            //FlushSessionAndEvict(stats);
            return stats;
        }
        public PlayerSeasonStats UpdatePlayerSeasonStats(PlayerFixture playerFixture, Season season)
        {
            PlayerSeasonStats playerSeasonStats;
            int totalPoints = 0;
            int totalFouls = 0;
            int mvpAwards = 0;

            // Get all PlayerFixture records for specified season
            List<PlayerFixture> playerFixturesForSeason = this.statsReportingService.GetPlayerFixtureStatsForSeason(playerFixture.Player.Id, season.Id).ToList();

            // Total stats
            foreach (PlayerFixture pf in playerFixturesForSeason)
            {
                totalPoints += pf.PointsScored;
                totalFouls += pf.Fouls;
                if (pf.IsMvp == "Y")
                    mvpAwards++;
            }

            // Find existing record
            playerSeasonStats = this.statsReportingService.GetPlayerSeasonStats(playerFixture.Player.Id, season.Id);

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

            // Save
            matchResultRepository.SavePlayerSeasonStats(playerSeasonStats);

            return playerSeasonStats;
        }
 public ActionResult Edit(PlayerSeasonStats @playerSeasonStats)
 {
     if (ModelState.IsValid) {
                 playerSeasonStatsService.Update(@playerSeasonStats);
                 playerSeasonStatsService.Commit();
                 SuccessMessage(FormMessages.SaveSuccess);
                 return RedirectToAction("Index");
         }
         return View(@playerSeasonStats);
 }
 public PlayerSeasonStats SavePlayerSeasonStats(PlayerSeasonStats playerSeasonStats)
 {
     playerSeasonStatsRepository.InsertOrUpdate(playerSeasonStats);
     return playerSeasonStats;
 }
        public static PlayerSeasonStats CreatePlayerSeasonStats(int id, Player player, Season season)
        {
            PlayerSeasonStats p = new PlayerSeasonStats(player, season, 100, 20, 5, 1);
            EntityIdSetter.SetIdOf(p, id);

            return p;
        }
        public static PlayerSeasonStats CreatePlayerSeasonStats()
        {
            PlayerSeasonStats p = new PlayerSeasonStats(CreatePlayer(), CreateSeason(), 100, 20, 5, 1);
            EntityIdSetter.SetIdOf(p, 1);

            return p;
        }