Ejemplo n.º 1
0
 public void lvMessages_InsertItem()
 {
     var db = new SimpleChatDbContext();
     var item = new Message();
     TryUpdateModel(item);
     if (ModelState.IsValid)
     {
         item.TimeStamp = DateTime.Now;
         db.Messages.Add(item);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 protected void SaveMessage_Click(object sender, EventArgs e)
 {
     var db = new SimpleChatDbContext();
     var item = new Message();
     item.TimeStamp = DateTime.Now;
     item.Author = this.Author.Text;
     item.Content = this.Content.Text;
     db.Messages.Add(item);
     db.SaveChanges();
     this.Author.Text = string.Empty;
     this.Content.Text = string.Empty;
     lvMessages.DataBind();
 }