Added Get well by id method in WellController

This commit is contained in:
KharchenkoVladimir 2021-10-20 16:18:07 +05:00
parent 4968ca4382
commit 167dd3d5f5
2 changed files with 27 additions and 2 deletions

View File

@ -96,11 +96,15 @@ namespace AsbCloudInfrastructure.Services
.ThenInclude(c => c.Deposit)
.FirstOrDefaultAsync(w => w.Id == idWell, token)
.ConfigureAwait(false);
var dto = entity.Adapt<WellDto>();
if (dto is null)
return dto;
dto.Cluster = entity.Cluster?.Caption;
dto.Deposit = entity.Cluster?.Deposit?.Caption;
return dto;
}
public async Task<string> GetWellCaptionByIdAsync(int idWell, CancellationToken token)

View File

@ -46,6 +46,27 @@ namespace AsbCloudWebApi.Controllers
return Ok(wells);
}
/// <summary>
/// Возвращает информацию о требуемой скважине
/// </summary>
/// <param name="idWell"> Id требуемой скважины </param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns>Информация о требуемой скважине </returns>
[HttpGet("getWell")]
[ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> 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);
}
/// <summary>
/// Возвращает список скважин, передающих телеметрию в данный момент
/// </summary>