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; }
public static void SaveGame(Game game) { using (var db = CreateDB()) { db.ExecuteWithParams("update game set Status = @Status, Serialized = @Serialized, Private = @Private where id = @Id", new { Id = game.Id, Status = game.Status, Serialized = game.Save(), @Private = (game.IsPrivate ? 1 : 0) }); } }