using System.Net;
using System.Text;
using MySql.Data.MySqlClient;

namespace Server
{
    public class Reset : Route
    {
        public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
        {
            try
            {
                // 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);
            }
        }
    }
}
