diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs index 7bf956f9..7059c593 100644 --- a/PARR.API/Contracts/V1/ApiRoutes.cs +++ b/PARR.API/Contracts/V1/ApiRoutes.cs @@ -99,6 +99,9 @@ namespace PARR.API.Contracts.V1 public static class Host { public const string GetAll = Base + "/hosts/"; + public const string Get = Base + "/hosts/" + getParam; + + public const string getParam = "{id}"; } public static class RobotHistoryLevel diff --git a/PARR.API/Controllers/V1/HostController.cs b/PARR.API/Controllers/V1/HostController.cs index 56ed8674..48434051 100644 --- a/PARR.API/Controllers/V1/HostController.cs +++ b/PARR.API/Controllers/V1/HostController.cs @@ -57,5 +57,30 @@ namespace PARR.API.Controllers.V1 return Ok(paginationResponse); } + + + /// + /// Получить хост по id + /// + /// + /// + [HttpGet(ApiRoutes.Host.Get)] + public async Task GetById([FromRoute] Guid id) + { + var host = await hostService.Get() + .Include(s => s.EkStatus) + .Include(s => s.ResponseArea) + .Include(t => t.ApplicationsInHosts).ThenInclude(t => t.Application).ThenInclude(t => t!.ApplicationType) + .FirstOrDefaultAsync(t => t.Id == id); + + if (host == null) + return NotFound(); + + var response = mapper.Map(host); + + return Ok(new Response(response, true)); + } + + } }