// The id parameter name should match the DataKeyNames value set on the control
        public void usersPosts_UpdateItem(int id)
        {

            var context = new UsersEntities();

            using (context)
            {
                var item = context.Posts.FirstOrDefault(p => p.Id == id);

                if (item == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("", String.Format("Item with id {0} was not found", id));
                    return;
                }
                TryUpdateModel(item);
                if (ModelState.IsValid)
                {
                    context.SaveChanges();

                }
            }

            
        }
        public IQueryable<Post> usersPosts_GetData()
        {
            var context = new UsersEntities();
            var posts = context.Posts;

            return posts;
        }
        // The id parameter name should match the DataKeyNames value set on the control
        public void usersPosts_DeleteItem(int id)
        {
            var context = new UsersEntities();
            using (context)
            {
                var post = context.Posts.FirstOrDefault(p => p.Id == id);
                context.Posts.Remove(post);

                context.SaveChanges();
            }
        }
        protected void makePostBtn_Click(object sender, EventArgs e)
        {
            var context = new UsersEntities();

            using (context)
            {
                var text = this.usersPostText.Text;
                var user = context.AspNetUsers.FirstOrDefault(u => u.UserName == User.Identity.Name);
                Post post = new Post()
                {
                    Text = text
                };
                user.Posts.Add(post);

                context.SaveChanges();

                this.usersPosts.DataBind();

            }
        }