Example #1
0
 public static void ClearHistory()
 {
     using (var context = new BingeContext())
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
     }
 }
Example #2
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     using (var context = new BingeContext()) {
         context.Database.EnsureCreated();
         context.Database.Migrate();
     }
 }
Example #3
0
 public static IEnumerable <CookieBinge> GetRecentBinges(int numberToRetrieve)
 {
     using (var context = new BingeContext())
     {
         return(context.Binges
                .OrderByDescending(b => b.TimeOccurred)
                .Take(numberToRetrieve).ToList());
     }
 }
Example #4
0
        public static void RecordBinge(int count, bool worthIt)
        {
            var binge = new CookieBinge
            {
                HowMany      = count,
                WorthIt      = worthIt,
                TimeOccurred = DateTime.Now
            };

            using (var context = new BingeContext())
            {
                context.Binges.Add(binge);
                context.SaveChanges();
            }
        }