Пример #1
0
        public void CalculateStats(NSSPingPongContext context)
        {
            Games         = Wins + Losses;
            WinPercentage = (Wins / Games) * 100;

            var gps = context.GamePlayer.Where(g => g.PlayerId == PlayerId);

            Double pointDiffCounter = 0;
            Double numOfGames       = gps.Count();

            foreach (GamePlayer gp in gps)
            {
                pointDiffCounter = pointDiffCounter + (double)gp.PointDiff;
            }

            AvgPointDiff = (pointDiffCounter / numOfGames);

            var gpSinglesGames = context.GamePlayer.Where(gp => gp.PlayerId == PlayerId && gp.Singles == true).ToList().Count();
            var gpSinglesWins  = context.GamePlayer.Where(gp => gp.PlayerId == PlayerId && gp.Singles == true && gp.Won == true).ToList().Count();
            var gpDoublesGames = context.GamePlayer.Where(gp => gp.PlayerId == PlayerId && gp.Singles == false).ToList().Count();
            var gpDoublesWins  = context.GamePlayer.Where(gp => gp.PlayerId == PlayerId && gp.Singles == false && gp.Won == true).ToList().Count();

            if (gpSinglesGames == 0 || gpDoublesGames == 0)
            {
                Rating = 0;
            }
            else
            {
                //Problem with Rating being 10,000 more than needed
                SinglesWinPercentage = (double)gpSinglesWins / (double)gpSinglesGames;
                DoublesWinPercentage = (double)gpDoublesWins / (double)gpDoublesGames;
                Rating = (((SinglesWinPercentage * .45) + (DoublesWinPercentage * .35) + (WinPercentage * .2)) * 10);
                SinglesWinPercentage = SinglesWinPercentage * 100;
                DoublesWinPercentage = DoublesWinPercentage * 100;
            }
        }
Пример #2
0
 public ReportsController(NSSPingPongContext ctx)
 {
     context = ctx;
 }
 public PlayersController(NSSPingPongContext ctx)
 {
     context = ctx;
 }
Пример #4
0
 public GamesController(NSSPingPongContext ctx)
 {
     context = ctx;
 }