From 167dd3d5f5ac7e3e245ee2605f7b6a1f53de8985 Mon Sep 17 00:00:00 2001 From: KharchenkoVladimir Date: Wed, 20 Oct 2021 16:18:07 +0500 Subject: [PATCH] Added Get well by id method in WellController --- .../Services/WellService.cs | 8 +++++-- AsbCloudWebApi/Controllers/WellController.cs | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs index 54a95cbe..cd194caa 100644 --- a/AsbCloudInfrastructure/Services/WellService.cs +++ b/AsbCloudInfrastructure/Services/WellService.cs @@ -96,11 +96,15 @@ namespace AsbCloudInfrastructure.Services .ThenInclude(c => c.Deposit) .FirstOrDefaultAsync(w => w.Id == idWell, token) .ConfigureAwait(false); - + var dto = entity.Adapt(); + + if (dto is null) + return dto; + dto.Cluster = entity.Cluster?.Caption; dto.Deposit = entity.Cluster?.Deposit?.Caption; - + return dto; } public async Task GetWellCaptionByIdAsync(int idWell, CancellationToken token) diff --git a/AsbCloudWebApi/Controllers/WellController.cs b/AsbCloudWebApi/Controllers/WellController.cs index 2590671f..364d0863 100644 --- a/AsbCloudWebApi/Controllers/WellController.cs +++ b/AsbCloudWebApi/Controllers/WellController.cs @@ -46,6 +46,27 @@ namespace AsbCloudWebApi.Controllers return Ok(wells); } + /// + /// Возвращает информацию о требуемой скважине + /// + /// Id требуемой скважины + /// Токен отмены задачи + /// Информация о требуемой скважине + [HttpGet("getWell")] + [ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)] + public async Task GetAsync(int idWell, CancellationToken token = default) + { + var idCompany = User.GetCompanyId(); + + if (idCompany is null) + return NoContent(); + + var well = await wellService.GetAsync(idWell, + token).ConfigureAwait(false); + + return Ok(well); + } + /// /// Возвращает список скважин, передающих телеметрию в данный момент ///