Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <ModelUsersDbContext, Configuration>());

            ModelUsersDbContext db = new ModelUsersDbContext();
            var userEntry          = db.User.FirstOrDefault(u => u.Name == "Counter");

            if (userEntry != null)
            {
                userEntry.Count += 1;

                var img = ImageConverter.CreateBitmapImage("Total users: " + userEntry.Count.ToString());
                img.Save(this.Response.OutputStream, ImageFormat.Jpeg);
                this.Response.ContentType = "image/png";

                db.SaveChanges();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<ModelUsersDbContext, Configuration>());

            ModelUsersDbContext db = new ModelUsersDbContext();
            var userEntry = db.User.FirstOrDefault(u => u.Name == "Counter");

            if (userEntry != null)
            {
                userEntry.Count += 1;
            
                var img = ImageConverter.CreateBitmapImage("Total users: " + userEntry.Count.ToString());
                img.Save(this.Response.OutputStream, ImageFormat.Jpeg);
                this.Response.ContentType = "image/png";

                db.SaveChanges();
            }            
        }