예제 #1
0
 public bool IsScoreAlreadySubmitted(string playerName, int level)
 {
     using (var dbContext = new EnigmaDataContext())
     {
         return(dbContext.Scores.Count(c => c.Player.ToLower() == playerName.ToLower() && c.Level == level) > 0);
     }
 }
예제 #2
0
 public ScoreEntity GetScore(string player)
 {
     using (var dbContext = new EnigmaDataContext())
     {
         return(dbContext.Scores.Where(s => s.Player.ToLower() == player.ToLower()).OrderByDescending(s => s.Score).FirstOrDefault());
     }
 }
예제 #3
0
 public List <ScoreEntity> GetAllScore()
 {
     using (var dbContext = new EnigmaDataContext())
     {
         return(dbContext.Scores.ToList());
     }
 }
예제 #4
0
 public void CleanUpScore()
 {
     using (var dbContext = new EnigmaDataContext())
     {
         var scores = dbContext.Scores;
         dbContext.RemoveRange(scores);
         dbContext.SaveChanges();
     }
 }
예제 #5
0
 public void AddNewScore(string player, int level, int time, int step)
 {
     using (var dbContext = new EnigmaDataContext())
     {
         ScoreEntity score = new ScoreEntity();
         score.Player = player;
         score.Level  = level;
         score.Time   = time;
         score.Step   = step;
         dbContext.Scores.Add(score);
         dbContext.SaveChanges();
     }
 }
예제 #6
0
 public void UpdateScore(string player, int level, int time, int step)
 {
     using (var dbContext = new EnigmaDataContext())
     {
         ScoreEntity score = dbContext.Scores.SingleOrDefault(c => c.Player.ToLower() == player.ToLower() && c.Level == level);
         if (score != null)
         {
             score.Level = level;
             score.Time  = time;
             score.Step  = step;
             dbContext.SaveChanges();
         }
     }
 }