public List<Word> GetWords(int Page, int PageSize)
 {
     using (var db = new LanguageBoosterContext())
     {
         return db.Words.OrderBy(w => w.Id).Skip(Page * PageSize).Take(PageSize).ToList();
     }
 }
 public int GetWordCount()
 {
     using (var db = new LanguageBoosterContext())
     {
         return db.Words.Count();
     }
 }
 public void CreatePlayer(Player NewPlayer)
 {
     using (var db = new LanguageBoosterContext())
     {
         db.Players.Attach(NewPlayer);
         db.Players.Add(NewPlayer);
         db.SaveChanges();
     }
 }
        public List<Score> GetHighscores()
        {
            List<Score> HighScores = new List<Score>();

            using (var db = new LanguageBoosterContext())
            {
                var ActualHighScores = db.Scores.OrderBy(score => -score.Value).Take(10);
                HighScores.AddRange(ActualHighScores);
            }

            return HighScores;
        }
        public Word GetNextWord(Player NewPlayer)
        {
            using (var db = new LanguageBoosterContext())
            {
                int Count = db.Words.Count();

                if (Count == 0)
                {
                    throw new Exception("No words set up!");
                }

                int RandomIndex = random.Next(Count - 1);

                return db.Words.Skip(RandomIndex).Single();
            }
        }
 public void SubmitScore(Score NewScore)
 {
     using (var db = new LanguageBoosterContext())
     {
         db.Scores.Attach(NewScore);
         db.Scores.Add(NewScore);
         db.SaveChanges();
     }
 }
        public void RemoveWord(Word word)
        {
            using (var db = new LanguageBoosterContext())
            {
                db.Database.ExecuteSqlCommand("DELETE FROM words WHERE id = " + word.Id);

                /*
                db.Words.Attach(word);
                db.Words.Remove(word);
                db.SaveChanges();
                */
            }
        }
 public void SubmitWord(Word NewWord)
 {
     using (var db = new LanguageBoosterContext())
     {
         db.Words.Add(NewWord);
         db.SaveChanges();
     }
 }