using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
///
/// Контроллер для коридоров бурения на панели
///
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class DrillFlowChartController : CrudWellRelatedController
{
private readonly ITelemetryService telemetryService;
private readonly IWellService wellService;
public DrillFlowChartController(IWellService wellService, IDrillFlowChartService service,
ITelemetryService telemetryService)
:base(wellService, service)
{
this.telemetryService = telemetryService;
this.wellService = wellService;
}
///
/// Возвращает все значения для коридоров бурения по uid панели
///
/// uid панели
/// Дата, с которой следует искать новые параметры
/// Токен отмены задачи
/// Список параметров для коридоров бурения
[HttpGet]
[Route("/api/telemetry/{uid}/drillFlowChart")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
public async Task GetByTelemetryAsync(string uid, DateTime updateFrom = default, CancellationToken token = default)
{
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
if (idWell is null)
return BadRequest($"Wrong uid {uid}");
var dto = await service.GetAllAsync((int)idWell,
updateFrom, token);
return Ok(dto);
}
}
}