private void SaveGame(Game game) { Db.Games.Add(game); var gameId = game.Id; foreach (var match in game.MyMatches.Values) { match.GameId = gameId; Db.Matches.Add(match); } Db.SaveChangesAsync(); }
private Game CreateGame(InvitationMessage message) { var newGame = new Game { GameSize = message.GameSize, Duration = DateTime.Now.TimeOfDay }; newGame.MyMatches.Add(message.SenderNick, new Match { PlayerNick = message.SenderNick }); newGame.MyMatches.Add(message.ReceiverNick, new Match { PlayerNick = message.ReceiverNick }); return(newGame); }