private static void AddHeroesToSql(IEnumerable<DummyHero> heroes, BoardgameSimulatorData data) { foreach (var hero in heroes) { data.Heroes.Add(new Hero { Name = hero.Name, UnitId = hero.UnitId, SkillId = hero.SkillId }); } data.SaveChanges(); }
private static void SeedDataFromMongoDb(BoardgameSimulatorData data, IEnumerable<DummySkill> skillsFromMongo, IEnumerable<DummyUnit> unitsFromMongo, IEnumerable<DummyAlignmentPerk> perksFromMongo, IEnumerable<DummyHero> heroesFromMongo, IEnumerable<DummyBattleLog> battleLogsFromMongo) { Console.WriteLine("Seeeding data from MongoDb into SQL initialized."); if (skillsFromMongo != null) { SeedSkills(data, skillsFromMongo); data.SaveChanges(); Console.WriteLine("Skill entries successfully seeded into SQL"); } if (unitsFromMongo != null) { SeedUnits(data, unitsFromMongo); data.SaveChanges(); Console.WriteLine("Unit entries successfully seeded into SQL"); } if (perksFromMongo != null) { SeedPerks(data, perksFromMongo); data.SaveChanges(); Console.WriteLine("Perk entries successfully seeded into SQL"); } if (heroesFromMongo != null) { SeedHeroes(data, heroesFromMongo); data.SaveChanges(); Console.WriteLine("Hero entries successfully seeded into SQL"); } if (battleLogsFromMongo != null) { SeedBattleLogs(data, battleLogsFromMongo); data.SaveChanges(); Console.WriteLine("BattleLog entries successfully seeded into SQL"); } Console.WriteLine("Seeeding data from MongoDb into SQL completed."); }
private static void AddItemsToSql(IEnumerable<DummyItem> items, BoardgameSimulatorData data) { foreach (var item in items) { data.Items.Add(new Item { Name = item.Name, DamageBonus = item.DamageBonus, HealthBonus = item.HealthBonus, HeroId = item.HeroId }); } data.SaveChanges(); }