Пример #1
0
 public void ClearRating()
 {
     using (var context = new ReversiDBContext())
     {
         context.Database.ExecuteSqlCommand("DELETE FROM Ratings");
     }
 }
Пример #2
0
 public void Rate(Rating rating)
 {
     using (var context = new ReversiDBContext())
     {
         context.Ratings.Add(rating);
         context.SaveChanges();
     }
 }
Пример #3
0
 public void AddScore(Score score)
 {
     using (var context = new ReversiDBContext())
     {
         context.Scores.Add(score);
         context.SaveChanges();
     }
 }
Пример #4
0
 public IList <Rating> GetLastRatings()
 {
     using (var context = new ReversiDBContext())
     {
         return((from r in context.Ratings
                 orderby r.Mark
                 descending
                 select r).Take(5).ToList());
     }
 }
Пример #5
0
 public IList <Score> GetTopScores()
 {
     using (var context = new ReversiDBContext())
     {
         return((from s in context.Scores
                 orderby s.Points
                 descending
                 select s).Take(5).ToList());
     }
 }
Пример #6
0
        public float GetAverageRating()
        {
            var   context = new ReversiDBContext();
            float total   = 0f;
            int   counter = 0;

            foreach (var r in context.Ratings)
            {
                total += r.Mark;
                counter++;
            }

            return((counter == 0) ? total : total / counter);
        }