static void AddHighScore(int playerScore) { Console.WriteLine("What is your name?"); string playerName = Console.ReadLine(); //create a gateway to the database HighScoresEntities db = new HighScoresEntities(); HighScore thisScore = new HighScore(); thisScore.Time = DateTime.Now; thisScore.Game = "Guess That Number"; thisScore.Name = playerName; thisScore.Score = playerScore; db.HighScores.Add(thisScore); db.SaveChanges(); }
static void AddHighScore(int playerScore) { Console.WriteLine("Your name: "); string playerName = Console.ReadLine(); //Create a gateway to the database KevinEntities db = new KevinEntities(); //Create new high score object HighScore newHighScore = new HighScore(); newHighScore.DateCreated = DateTime.Now; newHighScore.Game = "Guess That Number"; newHighScore.Name = playerName; newHighScore.Score = playerScore; //Add it to the database db.HighScores.Add(newHighScore); //Save changes to db db.SaveChanges(); }