Server gets created at registration now

This commit is contained in:
2026-01-08 12:13:49 +01:00
parent 6e17dcb270
commit 8cda82111d

View File

@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using watcher_monitoring.Payloads;
using watcher_monitoring.Data;
using watcher_monitoring.Models;
using Microsoft.AspNetCore.Authorization.Infrastructure;
namespace watcher_monitoring.Controllers;
@@ -35,7 +36,22 @@ public class MonitoringController : Controller
return BadRequest(new { error = "Invalid registration payload", details = errors });
}
try {
Server server = new Server
{
Name = "test",
IPAddress = dto.IpAddress
};
_context.Servers.Add(server);
await _context.SaveChangesAsync();
return Ok();
} catch (Exception ex)
{
Console.WriteLine(ex.Message);
_logger.LogError(ex.Message);
return BadRequest();
}
}
// Hardware Configuration Endpoint for watcher-agent