refractoring

This commit is contained in:
QkoSad
2024-12-05 12:09:30 +02:00
parent 926436860c
commit 80040638a6
37 changed files with 814 additions and 682 deletions
+19 -21
View File
@@ -1,32 +1,30 @@
using System.Net;
using MySql.Data.MySqlClient;
namespace Server
namespace Server;
public class Reset : Route
{
public class Reset : Route
public static void HandleRequest(HttpListenerResponse response)
{
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
try
{
try
// prepare SQL query
MySqlCommand cmd = new() { CommandText = "CALL InitDB" };
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
// prepare SQL query
MySqlCommand cmd = new MySqlCommand();
cmd.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);
cmd.Connection = conn;
// open connection
conn.Open();
// execute query
cmd.ExecuteNonQuery();
// set up and send response
SendSuccess(response);
}
}
catch (Exception ex)
{
SendError(response, ex);
}
}
}