public void AddMatch(long teamA, long teamB, bool winner)
        {
            int result = winner ? 1 : 0;

            double expectedOutcomeA = CalculateExpectedOutcome(teamA, teamB, 1);
            double expectedOutcomeB = CalculateExpectedOutcome(teamB, teamA, 1);

            BOTeam team1 = new BOTeam(teamA);
            BOTeam team2 = new BOTeam(teamB);

            team1.ELOValue = (long)Math.Round(team1.ELOValue + _K_VALUE * (result - expectedOutcomeA));
            team2.ELOValue = (long)Math.Round(team2.ELOValue + _K_VALUE * ((1 - result) - expectedOutcomeB));

            team1.Save();
            team2.Save();
        }
        /// <summary>
        /// Internal 0:Needs to be processed, 1:processing, 2:live event, 3:done, 4:elo done
        /// </summary>
        public void Process()
        {
            if (InternalStatus == 3 || InternalStatus == 1)
                return;
            if (InternalStatus == 0)
                InternalStatus = 1;
            Save();
            // This code needs to be moved
            WebClient Client = new WebClient();
            HTML = Client.DownloadString(this.URL);

            HtmlDocument document = new HtmlDocument();
            document.LoadHtml(HTML);
            HtmlNodeCollection matches = document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[1].SelectNodes("tr");

            if (matches != null)
            {
                long roundNumberPrevious = 0;
                BOMatch match = new BOMatch();

                foreach (HtmlNode row in matches)
                {
                    var columns = row.SelectNodes("td");
                    string link = columns[0].FirstChild.Attributes["href"].Value;
                    string externalID = columns[0].InnerText;
                    DateTime date = DateTime.Parse(columns[1].InnerText);
                    string Team1Short = columns[2].InnerText;
                    string Team1URL = columns[2].FirstChild.Attributes["href"].Value;
                    string Team2Short = columns[3].InnerText;
                    string Team2URL = columns[3].FirstChild.Attributes["href"].Value;
                    string winningSide = columns[4].InnerText;
                    long roundNubmer;
                    if (!string.IsNullOrEmpty(columns[6].InnerText))
                        roundNubmer = long.Parse(columns[6].InnerText);
                    else roundNubmer = 1;
                    float gameTime = float.Parse(columns[7].InnerText);
                    int scoreTeam1 = int.Parse(columns[8].InnerText.Split('-')[0].Trim());
                    int scoreTeam2 = int.Parse(columns[8].InnerText.Split('-')[1].Trim());

                    if (BOMatch.CheckExistingExternalID(long.Parse(externalID)))
                    {
                        BORound round = new BORound();

                        round.Winner = winningSide.ToUpper().Contains("RADIANT");
                        round.ScoreTeam1 = scoreTeam1;
                        round.ScoreTeam2 = scoreTeam2;
                        round.GameLengthMinutes = (int)gameTime;

                        if (roundNumberPrevious <= roundNubmer)
                        {// create a new match
                            match = new BOMatch();
                            match.Status = 1;
                            match.Event = this;
                        }
                        round.ExternalID = long.Parse(externalID);
                        round.Match = match;

                        BOTeam t1 = BOTeam.GetByName(Team1Short);
                        if(t1 == null)
                        {
                            t1 = new BOTeam();
                            t1.Name = Team1Short;
                            t1.Game = this.Game;
                            t1.ELOValue = BOTeam.DefaultELOValue;

                            t1.Save();
                        }
                        BOTeam t2 = BOTeam.GetByName(Team2Short);
                        if (t2 == null)
                        {
                            t2 = new BOTeam();
                            t2.Name = Team2Short;
                            t2.Game = this.Game;
                            t2.ELOValue = BOTeam.DefaultELOValue;

                            t2.Save();
                        }

                        round.RNDTeam1Team = t1;
                        round.RNDTeam2Team = t2;
                        round.OddsforTeam1 = 0;
                        round.BetsforTeam1 = 1;
                        match.Format = new BOFormat(1);
                        match.InternalStatus = 1;

                        match.Date = date;
                        round.Date = date;

                        round.ELO1 = 0;
                        round.ELO2 = 0;

                        match.Save();

                        round.Save();

                        roundNumberPrevious = roundNubmer;
                    }
                }
            }
        }