public LeagueViewModel(Event eventEntry)
        {
            IsFromHaxball = eventEntry.IsFromHaxball;

            if (IsFromHaxball)
            {
                Id = eventEntry.Id;
                HaxballLeagueId = eventEntry.HaxballLeagueId;
                SeasonNumber = eventEntry.SeasonNumber;

                League league = eventEntry.HaxballLeague;
                Title = league.Title;
                Players = league.Players;
                Winner = string.IsNullOrWhiteSpace(eventEntry.HardcodedWinner)
                    ? league.Winner
                    : eventEntry.HardcodedWinner;

                bool isFinished = league.Progress.Played >= league.Progress.Total;
                WrittenProgress = isFinished
                    ? "Finished"
                    : string.Format("In progress ({0}/{1})",
                        league.Progress.Played,
                        league.Progress.Total);
                HolidayImageUrl = isFinished
                    ? null
                    : string.Format("/HolidayImages/{0}.png", Id);
            }
            else
            {
                SeasonNumber = eventEntry.SeasonNumber;
                Status = eventEntry.Status;
                Url = eventEntry.Url;
                Title = eventEntry.Title;
                Winner = eventEntry.HardcodedWinner;
            }
        }
        private void RunLeague(Event eventEntry)
        {
            try
            {
                if (IsLeagueFinished(eventEntry.HaxballLeague))
                {
                    return;
                }

                logger.DebugFormat("Started parsing/updating leagueNumber: {0}", eventEntry.HaxballLeagueId);

                var url = string.Format("http://www.haxball.gr/league/view/{0}?g={1}",
                    eventEntry.HaxballLeagueId,
                    Guid.NewGuid().ToString("N"));

                HtmlDocument document =
                    new HtmlWeb().Load(url);

                var gamesNodes = document.DocumentNode.SelectNodes("//div[@id='fixtures']//div[@class='fixture-row']");

                if (gamesNodes == null)
                {
                    logger.DebugFormat(
                        "Probably league was removed from Haxball before it was finished. Id: {0}",
                        eventEntry.HaxballLeagueId);
                    return;
                }

                var newGames = new List<Game>();

                foreach (var gameNode in gamesNodes)
                {
                    var game = _gameParser.Parse(gameNode);
                    if (FakePlayersHelper.IsNotFake(game.HomePlayer) && FakePlayersHelper.IsNotFake(game.AwayPlayer))
                        newGames.Add(game);
                }

                var leagueParser = new LeagueParser();

                var playersNode = document.DocumentNode.SelectSingleNode("//div[@id='standings']");
                var players = leagueParser.GetPlayers(playersNode);
                var title = LeagueTitleParser.GetLeagueTitle(document);
                var winner = leagueParser.GetWinner(document.DocumentNode)
                             ?? eventEntry.HardcodedWinner;

                if (eventEntry.HaxballLeague == null)
                {
                    eventEntry.HaxballLeague = _leagueGamesUpdater.GetNewLeague(eventEntry.HaxballLeagueId, title,
                        newGames,
                        players, eventEntry.SeasonNumber, winner);
                }
                else
                {
                    eventEntry.HaxballLeague = _leagueGamesUpdater.UpdateLeague(eventEntry.HaxballLeague,
                        eventEntry.HaxballLeagueId, title,
                        newGames, players, eventEntry.SeasonNumber, winner);
                }

                var db = DbRepository.GetDb();
                db.UseOnceTo().Update(eventEntry);
            }
            catch (System.Exception ex)
            {
                logger.Warn("leagueNumber: " + eventEntry.HaxballLeagueId, ex);
            }
            finally
            {
                logger.DebugFormat("Finished parsing/updating leagueNumber: {0}", eventEntry.HaxballLeagueId);
            }
        }