using AsbCloudApp.Data;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers;
///
/// Редактор телеметрий для админки
///
[Route("api/admin/telemetry")]
[ApiController]
[Authorize]
public class AdminTelemetryController : CrudController>
{
private readonly ITelemetryService telemetryService;
private readonly ITelemetryDataEditorService telemetryEditorService;
public AdminTelemetryController(ICrudRepository service,
ITelemetryService telemetryService,
ITelemetryDataEditorService telemetryEditorService)
: base(service)
{
this.telemetryService = telemetryService;
this.telemetryEditorService = telemetryEditorService;
}
///
/// Merge telemetries. No body required.
///
///
[HttpPost("/merge/{idFrom}/{idTo}")]
[Permission]
public async Task MergeTelemetriesAsync(int idFrom, int idTo, CancellationToken token)
{
var count = await telemetryService.MergeAsync(idFrom, idTo, token)
.ConfigureAwait(false);
return Ok(count);
}
///
/// Удаление куска телеметрии по запросу
///
/// запрос
///
///
[HttpDelete("part")]
[Permission]
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task DeleteAsync([FromQuery] TelemetryPartDeleteRequest request,CancellationToken token)
{
var result = await telemetryEditorService.DeleteAsync(request, token);
return Ok(result);
}
}