/// <summary> /// Inserts the specified MSG. /// </summary> /// <param name="msg">The MSG.</param> public void Insert(Message msg) { using (var contex = new MessageContext()) { contex.Messages.Add(msg); contex.SaveChanges(); } }
protected void ButtonSend_Click(object sender, EventArgs e) { string messageText = this.TextBoxMessage.Text; var message = new Message() { MessageDateTime = DateTime.Now, MessageText = messageText }; var messageRepository = new MessageRepository(); messageRepository.Insert(message); }