31 lines
775 B
C#
31 lines
775 B
C#
using System.Net;
|
|
using MySql.Data.MySqlClient;
|
|
|
|
namespace TimelogBackend;
|
|
|
|
public class Reset : Route
|
|
{
|
|
public static void HandleRequest(HttpListenerResponse response)
|
|
{
|
|
try
|
|
{
|
|
// prepare SQL query
|
|
MySqlCommand cmd = new() { CommandText = "CALL InitDB" };
|
|
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
|
{
|
|
cmd.Connection = conn;
|
|
// open connection
|
|
conn.Open();
|
|
// execute query
|
|
cmd.ExecuteNonQuery();
|
|
// set up and send response
|
|
SendSuccess(response);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SendError(response, ex);
|
|
}
|
|
}
|
|
}
|