protected void SaveMessage_Click(object sender, EventArgs e)
 {
     var db = new ChatDbContext();
     var item = new Message();
     item.CreationDate = DateTime.Now;
     item.UserId = this.User.Identity.GetUserId();
     item.Content = this.Content.Text;
     db.Messages.Add(item);
     db.SaveChanges();
     this.Content.Text = string.Empty;
     lvMessages.DataBind();
 }
 public void lvMessages_InsertItem()
 {
     var db = new ChatDbContext();
     var item = new Message();
     TryUpdateModel(item);
     if (ModelState.IsValid)
     {
         item.CreationDate = DateTime.Now;
         db.Messages.Add(item);
         db.SaveChanges();
     }
 }
        public void MessagesListView_InsertItem()
        {
            var item = new Message();
            TryUpdateModel(item);
            item.CreationDate = DateTime.Now;
            item.UserId = this.User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                var db = new ChatDbContext();
                db.Messages.Add(item);
                db.SaveChanges();
            }
        }