private void SetupGames(MundialitoContext context, ITournamentCreator tournamentCreator) { var games = tournamentCreator.GetGames(stadiumsDic, teamsDic); games.ForEach(stadium => context.Games.Add(stadium)); context.SaveChanges(); if (monkeyEnabled) { var monkey = userManager.FindByName(WebConfigurationManager.AppSettings["MonkeyUserName"]); var randomResults = new RandomResults(); context.Games.ToList().ForEach(game => { var result = randomResults.GetRandomResult(); var newBet = new Bet(); newBet.UserId = monkey.Id; newBet.GameId = game.GameId; newBet.HomeScore = result.Key; newBet.AwayScore = result.Value; newBet.CardsMark = randomResults.GetRandomMark(); newBet.CornersMark = randomResults.GetRandomMark(); context.Bets.Add(newBet); }); context.SaveChanges(); } }
private void SetupGames(MundialitoContext context, ITournamentCreator tournamentCreator) { var games = tournamentCreator.GetGames(stadiumsDic, teamsDic); games.ForEach(stadium => context.Games.Add(stadium)); context.SaveChanges(); if (monkeyEnabled) { var monkey = userManager.FindByName(WebConfigurationManager.AppSettings["MonkeyUserName"]); var randomResults = new RandomResults(); context.Games.ToList().ForEach(game => { var result = randomResults.GetRandomResult(); var newBet = new Bet(); newBet.UserId = monkey.Id; newBet.GameId = game.GameId; newBet.HomeScore = result.Key; newBet.AwayScore = result.Value; newBet.CardsMark = randomResults.GetRandomMark(); newBet.CornersMark = randomResults.GetRandomMark(); context.Bets.Add(newBet); }); Random rnd = new Random(); var index = rnd.Next(0, teamsDic.Count); int teamId = teamsDic.Values.ElementAt(index).TeamId; index = rnd.Next(0, playersDic.Count); int playerId = playersDic.Values.ElementAt(index).PlayerId; context.GeneralBets.Add(new GeneralBet { GoldBootPlayerId = playerId, WinningTeamId = teamId, User = monkey }); context.SaveChanges(); } }