Example #1
0
 public ScoresViewModel()
 {
     using (var db = new UnicornClickerContext())
     {
         this.TopScores = db.GameScores
                          .OrderByDescending(s => s.ClicksPerSecond)
                          .Take(5)
                          .ToList();
     }
 }
Example #2
0
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using (var db = new UnicornClickerContext())
            {
                db.Database.Migrate();
            }
        }
Example #3
0
        private static void RecordGame(int duration, int clicks)
        {
            using (var db = new UnicornClickerContext())
            {
                db.GameScores.Add(new GameScore
                {
                    Clicks          = clicks,
                    Duration        = duration,
                    ClicksPerSecond = (double)clicks / duration,
                    Played          = DateTime.Now
                });

                db.SaveChanges();
            }
        }