public void SaveGuest(Guest guest)
        {
            var document = XDocument.Load(_settings.XmlConnectionString);
            var guestElement = new XElement("guest",
                new XElement("UserName", guest.UserName),
                new XElement("Message", guest.Message));

            document.Root.Add(guestElement);

            document.Save(_settings.XmlConnectionString);
        }
        public void SaveGuest(Guest guest)
        {
            using (var connection = new SQLiteConnection(_settings.SQLiteConnectionString))
            {
                var command = connection.CreateCommand();

                connection.Open();

                command.CommandType = CommandType.Text;
                command.CommandText = "INSERT INTO Users VALUES (null, '" + guest.UserName + "'); " +
                                      "INSERT INTO Messages VALUES (last_insert_rowid(), '" + guest.Message + "');";
                command.Parameters.Add(new SQLiteParameter("UserName", guest.UserName));
                command.Parameters.Add(new SQLiteParameter("Message", guest.Message));

                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 3
0
 public void SaveGuest(Guest guest)
 {
     _repository.SaveGuest(guest);
 }