switched to IpAddress as String
This commit is contained in:
@@ -10,7 +10,7 @@ using Watcher.ViewModels;
|
|||||||
|
|
||||||
public class HeartbeatDto
|
public class HeartbeatDto
|
||||||
{
|
{
|
||||||
public int ServerId { get; set; }
|
public string? IpAddress { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@@ -26,9 +26,15 @@ public class HeartbeatController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("receive")]
|
[HttpPost("receive")]
|
||||||
public async Task<IActionResult> Receive([FromBody] HeartbeatDto heartbeat)
|
public async Task<IActionResult> Receive([FromBody] HeartbeatDto dto)
|
||||||
{
|
{
|
||||||
var server = await _context.Servers.FirstOrDefaultAsync(s => s.Id == heartbeat.ServerId);
|
if (string.IsNullOrWhiteSpace(dto.IpAddress))
|
||||||
|
{
|
||||||
|
return BadRequest("Missing IP address.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var server = await _context.Servers
|
||||||
|
.FirstOrDefaultAsync(s => s.IPAddress == dto.IpAddress);
|
||||||
|
|
||||||
if (server != null)
|
if (server != null)
|
||||||
{
|
{
|
||||||
@@ -37,6 +43,6 @@ public class HeartbeatController : Controller
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
return BadRequest();
|
return NotFound("No matching server found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user