Ejemplo n.º 1
0
 public void ClearRating()
 {
     using (var context = new ReversiDBContext())
     {
         context.Database.ExecuteSqlCommand("DELETE FROM Ratings");
     }
 }
Ejemplo n.º 2
0
 public void Rate(Rating rating)
 {
     using (var context = new ReversiDBContext())
     {
         context.Ratings.Add(rating);
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void AddScore(Score score)
 {
     using (var context = new ReversiDBContext())
     {
         context.Scores.Add(score);
         context.SaveChanges();
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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);
        }