From 8cda82111d1e03f1543e886d5dc0f21bf689f09b Mon Sep 17 00:00:00 2001 From: triggermeelmo Date: Thu, 8 Jan 2026 12:13:49 +0100 Subject: [PATCH] Server gets created at registration now --- .../Controllers/MonitoringController.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/watcher-monitoring/Controllers/MonitoringController.cs b/watcher-monitoring/Controllers/MonitoringController.cs index f12b524..8028c05 100644 --- a/watcher-monitoring/Controllers/MonitoringController.cs +++ b/watcher-monitoring/Controllers/MonitoringController.cs @@ -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 }); } - return Ok(); + 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