33 lines
730 B
C#
33 lines
730 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using YD_TrainingCompetition_Api.Services;
|
|
|
|
namespace YD_TrainingCompetition_Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class HealthController : ControllerBase
|
|
{
|
|
private readonly IDeviceStateStore _store;
|
|
|
|
public HealthController(IDeviceStateStore store)
|
|
{
|
|
_store = store;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Get()
|
|
{
|
|
var devices = _store.GetAll();
|
|
|
|
return Ok(new
|
|
{
|
|
status = "ok",
|
|
service = "YD_TrainingCompetition_Api",
|
|
totalDevices = devices.Count,
|
|
onlineDevices = devices.Count(x => x.Online),
|
|
timestamp = DateTimeOffset.UtcNow
|
|
});
|
|
}
|
|
}
|
|
|