protected PlayerCareerStats AddPlayerCareerStats(Player player, int totalPoints, int totalFouls, int gamesPlayed, int mvpAwards)
        {
            PlayerCareerStats stats = new PlayerCareerStats(player, totalPoints, totalFouls, gamesPlayed, mvpAwards);

            //statsRepository.SaveOrUpdatePlayerCareerStats(stats);
            //FlushSessionAndEvict(stats);
            return(stats);
        }
예제 #2
0
        public static PlayerCareerStats CreatePlayerCareerStats()
        {
            PlayerCareerStats p = new PlayerCareerStats(CreatePlayer(), 100, 20, 5, 1);

            EntityIdSetter.SetIdOf(p, 1);

            return(p);
        }
        public PlayerCareerStats SavePlayerCareerStats(PlayerCareerStats playerCareerStats)
        {
            playerCareerStatsRepository.InsertOrUpdate(playerCareerStats);
            //Check.Require(!(playerCareerStats is IHasAssignedId<int>),
            //    "For better clarity and reliability, Entities with an assigned Id must call Save or Update");

            //Session.SaveOrUpdate(playerCareerStats);
            return playerCareerStats;
        }
예제 #4
0
        public PlayerCareerStats SavePlayerCareerStats(PlayerCareerStats playerCareerStats)
        {
            playerCareerStatsRepository.InsertOrUpdate(playerCareerStats);
            //Check.Require(!(playerCareerStats is IHasAssignedId<int>),
            //    "For better clarity and reliability, Entities with an assigned Id must call Save or Update");

            //Session.SaveOrUpdate(playerCareerStats);
            return(playerCareerStats);
        }
 public PlayerCareerStatsDto(PlayerCareerStats playerCareerStats)
 {
     this.Year          = "Career";
     this.Games         = playerCareerStats.GamesPlayed.ToString();
     this.MvpAwards     = playerCareerStats.MvpAwards.ToString();
     this.Fouls         = playerCareerStats.TotalFouls.ToString();
     this.FoulsPerGame  = playerCareerStats.FoulsPerGame.ToString("0.00");
     this.Points        = playerCareerStats.TotalPoints.ToString();
     this.PointsPerGame = playerCareerStats.PointsPerGame.ToString("0.00");
 }
 public PlayerCareerStatsDto(PlayerCareerStats playerCareerStats)
 {
     this.Year          = "Career";
     this.Games         = playerCareerStats.GamesPlayed.ToString();
     this.MvpAwards     = playerCareerStats.MvpAwards.ToString();
     this.Fouls         = playerCareerStats.TotalFouls.ToString();
     this.FoulsPerGame  = playerCareerStats.FoulsPerGame.ToString("0.00");
     this.Points        = playerCareerStats.TotalPoints.ToString();
     this.PointsPerGame = playerCareerStats.PointsPerGame.ToString("0.00");
 }
예제 #7
0
 public ActionResult Edit(PlayerCareerStats @playerCareerStats)
 {
     if (ModelState.IsValid)
     {
         playerCareerStatsService.Update(@playerCareerStats);
         playerCareerStatsService.Commit();
         SuccessMessage(FormMessages.SaveSuccess);
         return(RedirectToAction("Index"));
     }
     return(View(@playerCareerStats));
 }
예제 #8
0
        public void CanCreatePlayerCareerStatsWithZeroGamesPlayed()
        {
            Player player      = new Player("Phil", "Hale");
            int    totalPoints = -2;
            int    totalFouls  = 2;
            int    gamesPlayed = 0;
            int    mvpAwards   = 2;

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

            Assert.IsNotNull(stats);
            Assert.That(stats.Player, Is.EqualTo(player));
            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.GamesPlayed, Is.EqualTo(0));
            Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards));
        }
예제 #9
0
        public void CanCreatePlayerCareerStats()
        {
            Player player      = new Player("Phil", "Hale");
            int    totalPoints = 50;
            int    totalFouls  = 10;
            int    gamesPlayed = 4;
            int    mvpAwards   = 1;

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

            Assert.IsNotNull(stats);
            Assert.That(stats.Player, Is.EqualTo(player));
            Assert.That(stats.TotalPoints, Is.EqualTo(totalPoints));
            Assert.That(stats.PointsPerGame, Is.EqualTo(12.5f));
            Assert.That(stats.TotalFouls, Is.EqualTo(totalFouls));
            Assert.That(stats.FoulsPerGame, Is.EqualTo(2.5f));
            Assert.That(stats.GamesPlayed, Is.EqualTo(gamesPlayed));
            Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards));
        }
        public void CanCreatePlayerCareerStatsWithZeroGamesPlayed()
        {
            Player player = new Player("Phil", "Hale");
            int totalPoints = -2;
            int totalFouls = 2;
            int gamesPlayed = 0;
            int mvpAwards = 2;

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

            Assert.IsNotNull(stats);
            Assert.That(stats.Player, Is.EqualTo(player));
            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.GamesPlayed, Is.EqualTo(0));
            Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards));
        }
        public void CanCreatePlayerCareerStats()
        {
            Player player = new Player("Phil", "Hale");
            int totalPoints = 50;
            int totalFouls = 10;
            int gamesPlayed = 4;
            int mvpAwards = 1;

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

            Assert.IsNotNull(stats);
            Assert.That(stats.Player, Is.EqualTo(player));
            Assert.That(stats.TotalPoints, Is.EqualTo(totalPoints));
            Assert.That(stats.PointsPerGame, Is.EqualTo(12.5f));
            Assert.That(stats.TotalFouls, Is.EqualTo(totalFouls));
            Assert.That(stats.FoulsPerGame, Is.EqualTo(2.5f));
            Assert.That(stats.GamesPlayed, Is.EqualTo(gamesPlayed));
            Assert.That(stats.MvpAwards, Is.EqualTo(mvpAwards));
        }
        public PlayerCareerStats UpdatePlayerCareerStats(PlayerFixture playerFixture)
        {
            PlayerCareerStats playerCareerStats;
            int totalPoints = 0;
            int totalFouls  = 0;
            int mvpAwards   = 0;

            // Get all PlayerFixture records for all seasons
            List <PlayerFixture> playerFixturesForCareer = this.statsReportingService.GetPlayerFixtureStatusForAllSeasons(playerFixture.Player.Id).ToList();

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

            // Find existing record
            playerCareerStats = this.statsReportingService.GetPlayerCareerStatsByPlayerId(playerFixture.Player.Id);

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

            // Save
            matchResultRepository.SavePlayerCareerStats(playerCareerStats);

            return(playerCareerStats);
        }
        public PlayerStatsDto(Player player, List <PlayerFixture> currentSeasonFixtureStats, List <Fixture> currentSeasonFixtures, List <PlayerSeasonStats> seasonStats, PlayerCareerStats careerStats)
        {
            this.Player = player;

            CurrentSeasonFixtureStats = new List <PlayerSeasonFixtureStatsDto>();
            foreach (var stat in currentSeasonFixtureStats)
            {
                CurrentSeasonFixtureStats.Add(new PlayerSeasonFixtureStatsDto(stat, currentSeasonFixtures.Where(x => x.Id == stat.Fixture.Id).Single()));
            }

            CareerStats = new List <PlayerCareerStatsDto>();
            foreach (var stat in seasonStats)
            {
                CareerStats.Add(new PlayerCareerStatsDto(stat));
            }

            CareerStats.Add(new PlayerCareerStatsDto(careerStats));
        }
 public ActionResult Edit(PlayerCareerStats @playerCareerStats)
 {
     if (ModelState.IsValid) {
                 playerCareerStatsService.Update(@playerCareerStats);
                 playerCareerStatsService.Commit();
                 SuccessMessage(FormMessages.SaveSuccess);
                 return RedirectToAction("Index");
         }
         return View(@playerCareerStats);
 }
        public static PlayerCareerStats CreatePlayerCareerStats()
        {
            PlayerCareerStats p = new PlayerCareerStats(CreatePlayer(), 100, 20, 5, 1);
            EntityIdSetter.SetIdOf(p, 1);

            return p;
        }
        protected PlayerCareerStats AddPlayerCareerStats(Player player, int totalPoints, int totalFouls, int gamesPlayed, int mvpAwards)
        {
            PlayerCareerStats stats = new PlayerCareerStats(player, totalPoints, totalFouls, gamesPlayed, mvpAwards);

            //statsRepository.SaveOrUpdatePlayerCareerStats(stats);
            //FlushSessionAndEvict(stats);
            return stats;
        }
        public PlayerCareerStats UpdatePlayerCareerStats(PlayerFixture playerFixture)
        {
            PlayerCareerStats playerCareerStats;
            int totalPoints = 0;
            int totalFouls = 0;
            int mvpAwards = 0;

            // Get all PlayerFixture records for all seasons
            List<PlayerFixture> playerFixturesForCareer = this.statsReportingService.GetPlayerFixtureStatusForAllSeasons(playerFixture.Player.Id).ToList();

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

            // Find existing record
            playerCareerStats = this.statsReportingService.GetPlayerCareerStatsByPlayerId(playerFixture.Player.Id);

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

            // Save
            matchResultRepository.SavePlayerCareerStats(playerCareerStats);

            return playerCareerStats;
        }
예제 #18
0
        public ActionResult Edit(int id)
        {
            PlayerCareerStats @playerCareerStats = playerCareerStatsService.Get(id);

            return(View(@playerCareerStats));
        }