Esempio n. 1
0
        //display info from high score
        static void InfoFromDB()
        {
            Console.WriteLine("Press Enter to see high scores");
            Console.ReadKey();
            Console.Clear();

            JayaEntities db = new JayaEntities();

            List<HighScore> highScoreList = db.HighScores.Where(x => x.Game == "Trivia").OrderByDescending(x => x.Score).Take(10).ToList();

            foreach (var item in highScoreList)
            {
                Console.WriteLine("{0}, {1}{2}", highScoreList.IndexOf(item) + 1, item.Name, item.Score);
            }
        }
Esempio n. 2
0
        //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();
        }