static void AddHighScore(int playerScore) { Console.WriteLine("Your Name: "); string playerName = Console.ReadLine(); //create a gateway to the database MorganEntities db = new MorganEntities(); //create a new highsccore object HighScore newHighScore = new HighScore(); newHighScore.DateCreated = DateTime.Now; newHighScore.Game = "Trivia Game"; newHighScore.Name = playerName; newHighScore.Score = playerScore; //add it to the database db.HighScores.Add(newHighScore); //save our changes db.SaveChanges(); }
//add to db static void AddToDB() { //connection to db JayaEntities db = new JayaEntities(); HighScore currentScore = new HighScore(); //add all info to current score currentScore.DateCreated = DateTime.Now; currentScore.Game = "Trivia"; currentScore.Name = name; currentScore.Score = score; db.HighScores.Add(currentScore); db.SaveChanges(); }
static void AddHighScore(int playerScore) { Console.WriteLine("Add your name to high scores list: "); 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 = "Trivia"; newHighScore.Name = playerName; newHighScore.Score = playerScore; //Add it to the database db.HighScores.Add(newHighScore); //Save changes to db db.SaveChanges(); }