public static void SetGdbId(int GameId, int GdbId) { Game game = GetGame(GameId); game.gdbId = GdbId; SetGame(game); // GameListBuilder.UpdateFlag(); GamesLibraryVisualHandler.DoGameUpdate(new List <Game> { game }); }
public static void SetGame(Game game, bool init) { using (var cfDef = new MyDbContext()) { cfDef.Entry(game).State = Microsoft.Data.Entity.EntityState.Modified; cfDef.SaveChanges(); GamesLibraryVisualHandler.DoGameUpdate(new List <Game> { game }); } }
public static void SetStartedPlaying(int gameId) { Game game = GetGame(gameId); game.gameLastPlayed = DateTime.Now; SetGame(game); // GameListBuilder.UpdateFlag(); GamesLibraryVisualHandler.DoGameUpdate(new List <Game> { game }); }
private static void UpdateRom(Game rom) { using (var uR = new MyDbContext()) { uR.Game.Update(rom); uR.SaveChanges(); uR.Dispose(); } List <Game> games = new List <Game>(); games.Add(rom); GamesLibraryVisualHandler.DoGameUpdate(games); }
public static void SaveToDatabase(List <Game> games, bool init) { using (var db = new MyDbContext()) { // get current database context var current = db.Game.AsNoTracking().ToList(); List <Game> toAdd = new List <Game>(); List <Game> toUpdate = new List <Game>(); // iterate through the games list and separete out games to be added and games to be updated foreach (var g in games) { Game t = (from a in current where a.gameId == g.gameId select a).SingleOrDefault(); if (t == null) { toAdd.Add(g); } else { toUpdate.Add(g); } } db.Game.UpdateRange(toUpdate); db.Game.AddRange(toAdd); db.SaveChanges(); App _App = (App)Application.Current; if (_App.GamesLibrary == null) { return; } if (toAdd.Count > 0) { GamesLibraryVisualHandler.DoGameAdd(toAdd); } if (toUpdate.Count > 0) { GamesLibraryVisualHandler.DoGameUpdate(toUpdate); } } }