private void SaveGame(BattleshipsServiceLibrary.Game game) { using (BattleshipsDbEntities bdc = new BattleshipsDbEntities()) { BattleshipsDatabase.Game g = new BattleshipsDatabase.Game(); g.End = DateTime.Now; g.Winner = game.Winner.PlayerId; g.Loser = game.Opponent(g.Winner).PlayerId; g.Start = game.Start; foreach (Move m in game.Moves) { bdc.Turns.Add(new Turn() { Game = g.GameId, Player = m.Player, Time = m.Time, Hit = m.Result == BlockState.HIT, X = m.AtX, Y = m.AtY }); } bdc.Games.Add(g); bdc.SaveChanges(); } }