public static IApplicationBuilder MigrateDatabase(this IApplicationBuilder app) { GoTGameContextDb context = app.ApplicationServices.GetRequiredService <GoTGameContextDb>(); context.Database.Migrate(); IdentityContextDb identityContext = app.ApplicationServices.GetRequiredService <IdentityContextDb>(); identityContext.Database.Migrate(); return(app); }
public static IApplicationBuilder UseGoTStorage(this IApplicationBuilder app) { IGoTStorage storage = app.ApplicationServices.GetRequiredService <IGoTStorage>(); GoTGameContextDb context = app.ApplicationServices.GetRequiredService <GoTGameContextDb>(); var games = context.Games.ToList(); foreach (Game game in games) { var playerIds = context.Players.Where(p => p.GameId == game.Id).Select(p => p.Id).ToArray(); storage.CreateGameStorage(game.Id, playerIds); } return(app); }
public static void PopulateGame(IApplicationBuilder app) { GoTGameContextDb context = app.ApplicationServices.GetRequiredService <GoTGameContextDb>(); IChatRepository chatRepo = app.ApplicationServices.GetRequiredService <IChatRepository>(); bool saveNeeded = false; if (!context.Games.Any()) { context.Games.AddRange(new[] { new Game { Name = "Temporary game", GameRules = new GameRules { AllHouses = false, RandomHouses = false, MaxPlayers = 6, WinCondition = WinCondition.Castles, WinCastlesCount = 7, RoundsCount = 10 } } }); saveNeeded = true; } if (saveNeeded) { context.SaveChanges(); } foreach (var game in context.Games) { chatRepo.CreateGameChat(game.Id, "Public"); } }
public ChatRepository(GoTGameContextDb context, IGoTStorage storage, IPlayersRepository playersRepository) : base(context, storage) { gameChats = new List <GameChat>(); this.playersRepository = playersRepository; }
public PlayersRepository(GoTGameContextDb context, IGoTStorage storage, IGamesRepository gamesRepo) : base(context, storage) { gamesRepository = gamesRepo; }
public BaseRepository(GoTGameContextDb context, IGoTStorage storage) { this.context = context; this.storage = storage; }
public GameRulesRepository(GoTGameContextDb context) { this.context = context; }
public GamesRepository(GoTGameContextDb context, IPasswordHasher <Game> passwordHasher) { this.context = context; this.passwordHasher = passwordHasher; }