public void Remove(SingleplayerSavedGameInfo savedGameInfo) { using (DbContextTransaction transaction = Database.BeginTransaction()) { try { var objectToBeRemoved = SingleplayerSavedGameInfos.First(x => x.Id == savedGameInfo.Id); string path = objectToBeRemoved.Path; SingleplayerSavedGameInfos.Remove(objectToBeRemoved); File.Delete(path); SaveChanges(); transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } } }
public byte[] LoadGame(SingleplayerSavedGameInfo info) { var savedGameInfo = SingleplayerSavedGameInfos.First(x => x.Id == info.Id); return(savedGameInfo.GetFileBytes()); }