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