Example #1
0
        private void MakeAnalysis(FootballGamePM game, string prediction, bool winCondition, bool deleteCondition)
        {
            if (!game.Predictions.Any(p => p.Name == prediction))
            {
                return;
            }

            PredictionSM predict = game.Predictions.Where(p => p.Name == prediction).FirstOrDefault();

            // That is only for pased games. The new games havn't play yet and they don't have statistics.
            if (deleteCondition)
            {
                game.Predictions.Remove(predict);
                return;
            }

            if (winCondition)
            {
                predict.Result = ServiceConstants.Yes;
            }
            else
            {
                predict.Result = ServiceConstants.No;
            }
        }
Example #2
0
        public void ATCorners()
        {
            double hTHomeAllowedCornersAvg = HTGames.Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName).Sum(g => g.GameStatistic.AwayTeamCorners) / (double)HTGames.Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName).Count();
            double hTAwayAllowedCornersAvg = HTGames.Where(g => g.AwayTeam.UniqueName == this.HomeTeam.UniqueName).Sum(g => g.GameStatistic.HomeTeamCorners) / (double)HTGames.Where(g => g.AwayTeam.UniqueName == this.HomeTeam.UniqueName).Count();

            double aTHomeCornersAvg = ATGames.Where(g => g.HomeTeam.UniqueName == this.AwayTeam.UniqueName).Sum(g => g.GameStatistic.HomeTeamCorners) / (double)ATGames.Where(g => g.HomeTeam.UniqueName == this.AwayTeam.UniqueName).Count();
            double aTAwayCornersAvg = ATGames.Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName).Sum(g => g.GameStatistic.AwayTeamCorners) / (double)ATGames.Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName).Count();

            double aTCornersAvg = (hTHomeAllowedCornersAvg + hTAwayAllowedCornersAvg + aTHomeCornersAvg + aTAwayCornersAvg) / 4.0;
            double aTCorners    = Math.Floor(aTCornersAvg) - 1;

            PredictionSM predict;

            if (!this.Predictions.Any(p => p.Name == ServiceConstants.ATCorners))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.ATCorners, Procent = aTCorners
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.ATCorners).FirstOrDefault();
                predict.Procent = aTCorners;
            }

            this.SumPredictCorners += aTCorners;
        }
Example #3
0
        private void Under12Corners()
        {
            var hTAllGamesCorners = this.HTGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) < 12).Count() /
                                    (double)this.HTGames.Count() * 100;
            var hTHomeGamesCorners = this.HTHomeGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) < 12).Count() /
                                     (double)this.HTHomeGames.Count() * 100;
            double hTUnder12Corners = hTAllGamesCorners * 0.3 + hTHomeGamesCorners * 0.7;

            var aTAllGamesCorners = this.ATGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) < 12).Count() /
                                    (double)this.ATGames.Count() * 100;
            var aTAwayGamesCorners = this.ATAwayGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) < 12).Count() /
                                     (double)this.ATAwayGames.Count() * 100;
            double aTUnder12Corners = aTAllGamesCorners * 0.3 + aTAwayGamesCorners * 0.7;

            double under12Corners = (hTUnder12Corners + aTUnder12Corners) / 2.0;

            PredictionSM predict;

            if (!this.Predictions.Any(p => p.Name == ServiceConstants.Under12Corners))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.Under12Corners, Procent = under12Corners
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.Under12Corners).FirstOrDefault();
                predict.Procent = under12Corners;
            }
        }
        public void ResultDraw()
        {
            double hTAllGamesDraws = this.HTAllGames
                                     .Where(g => (g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D) ||
                                            (g.AwayTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D))
                                     .Count() / (double)this.MinHTAllGamesCount * 100;
            double hTAllHomeGameDraws = this.HTAllHomeGames
                                        .Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D)
                                        .Count() / (double)this.MinHTAllHomeGamesCount * 100;
            double hTLastGamesDraws = this.HTLastGames
                                      .Where(g => (g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D) ||
                                             (g.AwayTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D))
                                      .Count() / (double)this.MinHTLastGamesCount * 100;
            double hTLastHomeGamesDraws = this.HTLastHomeGames
                                          .Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D)
                                          .Count() / (double)this.MinHTLastHomeGamesCount * 100;

            double hTDraw = hTAllGamesDraws * 0.3 + hTAllHomeGameDraws * 0.3 + hTLastGamesDraws * 0.2 + hTLastHomeGamesDraws * 0.2;

            double aTAllGamesDraws = this.ATAllGames
                                     .Where(g => (g.HomeTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D) ||
                                            (g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D))
                                     .Count() / (double)this.MinATAllGamesCount * 100;
            double aTAllAwayGamesDraws = this.ATAllAwayGames
                                         .Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D)
                                         .Count() / (double)this.MinATAllAwayGamesCount * 100;
            double aTLastGamesDraws = this.ATLastGames
                                      .Where(g => (g.HomeTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D) ||
                                             (g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D))
                                      .Count() / (double)this.MinATLastGamesCount * 100;
            double aTLastAwayGamesDraws = this.ATLastAwayGames
                                          .Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D)
                                          .Count() / (double)this.MinATLastAwayGamesCount * 100;

            double aTDraw = aTAllGamesDraws * 0.3 + aTAllAwayGamesDraws * 0.3 + aTLastGamesDraws * 0.2 + aTLastAwayGamesDraws * 0.2;

            double procent = hTDraw * 0.5 + aTDraw * 0.5;

            // Games between the both teams
            if (this.drawsBothTeams > 0)
            {
                procent += this.drawsBothTeams * 0.2;
            }

            PredictionSM predict;

            if (this.Predictions.Count() == 0 || !this.Predictions.Any(p => p.Name == ServiceConstants.Draw))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.Draw, Procent = procent
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.Draw).FirstOrDefault();
                predict.Procent = procent;
            }
        }
        public void Result2()
        {
            double hTAllGamesLosses = this.HTAllGames.
                                      Where(g => (g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A) ||
                                            (g.AwayTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H))
                                      .Count() / (double)MinHTAllGamesCount * 100;
            double hTAllHomeGamesLosses = this.HTAllHomeGames
                                          .Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A)
                                          .Count() / (double)this.MinHTAllHomeGamesCount * 100;
            double hTLastGamesLosses = this.HTLastGames
                                       .Where(g => (g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A) ||
                                              (g.AwayTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H))
                                       .Count() / (double)this.MinHTLastGamesCount * 100;
            double hTLastHomeGamesLosses = this.HTLastHomeGames
                                           .Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A)
                                           .Count() / (double)this.MinHTLastHomeGamesCount * 100;

            double hTLosses = (hTAllGamesLosses + hTAllHomeGamesLosses + hTLastGamesLosses + hTLastHomeGamesLosses) / 4.0;

            double aTAllGamesWins = this.ATAllGames
                                    .Where(g => (g.HomeTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H) ||
                                           (g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A))
                                    .Count() / (double)this.MinATAllGamesCount * 100;
            double aTAllAwayGamesWins = this.ATAllAwayGames
                                        .Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A)
                                        .Count() / (double)this.MinATAllAwayGamesCount * 100;
            double aTLastGamesWins = this.ATLastGames
                                     .Where(g => (g.HomeTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H) ||
                                            (g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A))
                                     .Count() / (double)this.MinATLastGamesCount * 100;
            double aTLastAwayGamesWins = this.ATLastAwayGames
                                         .Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A)
                                         .Count() / (double)this.MinATLastAwayGamesCount * 100;

            double aTWins = (aTAllGamesWins + aTAllAwayGamesWins + aTLastGamesWins + aTLastAwayGamesWins) / 4.0;

            double procent = (hTLosses + aTWins) / 2.0;

            PredictionSM predict;

            if (this.Predictions.Count() == 0 || !this.Predictions.Any(p => p.Name == ServiceConstants.ATWin))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.ATWin, Procent = procent
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.ATWin).FirstOrDefault();
                predict.Procent = procent;
            }

            this.aTWin = procent;
        }
        public void DivideBetweenHomeAndAway()
        {
            double divide = Math.Abs(this.hTWin - this.aTWin);

            PredictionSM predict;

            if (this.Predictions.Count() == 0 || !this.Predictions.Any(p => p.Name == ServiceConstants.Divide))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.Divide, Procent = divide
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.Divide).FirstOrDefault();
                predict.Procent = divide;
            }

            this.Divide = divide;
        }
Example #7
0
        public void SumCorners()
        {
            double sum = this.SumPredictCorners;

            PredictionSM predict;

            if (!this.Predictions.Any(p => p.Name == ServiceConstants.SumCorners))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.SumCorners, Procent = sum
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.SumCorners).FirstOrDefault();
                predict.Procent = sum;
            }

            this.SumPredictCorners = sum;
        }
Example #8
0
        private void Over8Corners()
        {
            var hTAllGamesCorners = this.HTGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) > 8).Count() /
                                    (double)this.HTGames.Count() * 100;
            var hTHomeGamesCorners = this.HTHomeGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) > 8).Count() /
                                     (double)this.HTHomeGames.Count() * 100;
            double hTOver8Corners = hTAllGamesCorners * 0.3 + hTHomeGamesCorners * 0.7;

            var aTAllGamesCorners = this.ATGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) > 8).Count() /
                                    (double)this.ATGames.Count() * 100;
            var aTAwayGamesCorners = this.ATAwayGames.Where(g => (g.GameStatistic.HomeTeamCorners + g.GameStatistic.AwayTeamCorners) > 8).Count() /
                                     (double)this.ATAwayGames.Count() * 100;
            double aTOver8Corners = aTAllGamesCorners * 0.3 + aTAwayGamesCorners * 0.7;

            double over8Corners = (hTOver8Corners + aTOver8Corners) / 2.0;

            //if (this.SumPredictCorners < 8)
            //{
            //    over8Corners -= 20;
            //}

            PredictionSM predict;

            if (!this.Predictions.Any(p => p.Name == ServiceConstants.Over8Corners))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.Over8Corners, Procent = over8Corners
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.Over8Corners).FirstOrDefault();
                predict.Procent = over8Corners;
            }
        }
        public void GamesBothTeams()
        {
            if (this.GamesBetweenBothTeams == null || this.GamesBetweenBothTeams.Count() < 5 ||
                this.GamesBetweenBothTeams.Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName).Count() < 1)
            {
                return;
            }

            int allGamesCount    = this.GamesBetweenBothTeams.Count();
            int hTHomeGamesCount = this.GamesBetweenBothTeams.Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName).Count();

            // Home team wins between both teams
            double hTAllGamesWins = this.GamesBetweenBothTeams
                                    .Where(g => (g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H) ||
                                           (g.AwayTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A))
                                    .Count() / (double)allGamesCount * 100;
            double hTAllHomeGamesWins = this.GamesBetweenBothTeams
                                        .Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H)
                                        .Count() / (double)hTHomeGamesCount * 100;

            double hTWin = hTAllGamesWins * 0.8 + hTAllHomeGamesWins * 0.2;

            PredictionSM predict;

            if (this.Predictions.Count() == 0 || !this.Predictions.Any(p => p.Name == ServiceConstants.HTWinBetweenBothTeams))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.HTWinBetweenBothTeams, Procent = hTWin
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.HTWinBetweenBothTeams).FirstOrDefault();
                predict.Procent = hTWin;
            }

            // Away team wins between both teams
            double aTAllGamesWins = this.GamesBetweenBothTeams
                                    .Where(g => (g.HomeTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.H) ||
                                           (g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A))
                                    .Count() / (double)allGamesCount * 100;
            double aTAllAwayGamesWins = this.GamesBetweenBothTeams
                                        .Where(g => g.AwayTeam.UniqueName == this.AwayTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.A)
                                        .Count() / (double)hTHomeGamesCount * 100;

            double aTWin = aTAllGamesWins * 0.8 + aTAllAwayGamesWins * 0.2;

            if (this.Predictions.Count() == 0 || !this.Predictions.Any(p => p.Name == ServiceConstants.ATWinBetweenBothTeams))
            {
                predict = new PredictionSM {
                    Name = ServiceConstants.ATWinBetweenBothTeams, Procent = aTWin
                };
                this.Predictions.Add(predict);
            }
            else
            {
                predict         = this.Predictions.Where(p => p.Name == ServiceConstants.ATWinBetweenBothTeams).FirstOrDefault();
                predict.Procent = aTWin;
            }

            // Draws
            var allGameDrawsProcent  = this.GamesBetweenBothTeams.Where(g => g.FullTimeResult.Result == ResultEnum.D).Count() / (double)allGamesCount * 100;
            var homeGameDrawsProcent = this.GamesBetweenBothTeams
                                       .Where(g => g.HomeTeam.UniqueName == this.HomeTeam.UniqueName && g.FullTimeResult.Result == ResultEnum.D).Count() / (double)hTHomeGamesCount * 100;

            this.drawsBothTeams = allGameDrawsProcent * 0.1 + homeGameDrawsProcent * 0.9;
        }