38 lines
950 B
C#
38 lines
950 B
C#
using Management.Data;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Management.Controllers;
|
|
|
|
/// <summary>
|
|
/// Test endpoints (anonymous, no auth required).
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/test")]
|
|
public class TestController : ControllerBase
|
|
{
|
|
private readonly SqlService _sql;
|
|
|
|
public TestController(SqlService sql)
|
|
{
|
|
_sql = sql;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Database connectivity test.
|
|
/// </summary>
|
|
[HttpGet("ping")]
|
|
public async Task<IActionResult> Ping(CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var resp = await _sql.ExecProcAsync("dbo.spTemplate", "ping",
|
|
"""{ "clientId":"00000000-0000-0000-0000-000000000001" }""", ct: ct);
|
|
return Content(resp, "application/json");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, new { ok = false, error = "Database connection failed", detail = ex.Message });
|
|
}
|
|
}
|
|
}
|