public static void SaveNewGame(Game game)
{
using (var db = CreateDB())
{
db.ExecuteWithParams("insert into game (Status, Serialized, Private) values (@Status, @Serialized, @Private) ", new { Status = game.Status, Serialized = game.Save(), @Private = (game.IsPrivate ? 1 : 0) });
game.Id = (int)db.LastInsertID;
if (String.IsNullOrEmpty(game.GameName))
game.GameName = "Game #" + game.Id;
}
// save the new id
SaveGame(game);
// insert into cache
HttpContext.Current.Cache[game.Id.ToString()] = game;
}