//opslaan contactformulier in database private void SavePerson(Personmodel person) { using (MySqlConnection conn = new MySqlConnection(connectionString)) { conn.Open(); MySqlCommand cmd = new MySqlCommand("INSERT INTO klant(naam, achternaam, emailadres, bericht) VALUES(?voornaam, ?achternaam,?email,?bericht)", conn); cmd.Parameters.Add("?voornaam", MySqlDbType.VarChar).Value = person.Voornaam; cmd.Parameters.Add("?achternaam", MySqlDbType.VarChar).Value = person.Achternaam; cmd.Parameters.Add("?email", MySqlDbType.VarChar).Value = person.Email; cmd.Parameters.Add("?bericht", MySqlDbType.VarChar).Value = person.Bericht; cmd.ExecuteNonQuery(); } }
public IActionResult Contact(Personmodel model) { if (!ModelState.IsValid) { return(View(model)); } SavePerson(model); ViewData["formsucces"] = "ök"; return(View()); }