DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/AdminTelemetryController.cs
2021-12-17 13:04:33 +05:00

39 lines
1.2 KiB
C#

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
[Route("api/admin/telemetry")]
[ApiController]
[Authorize]
public class AdminTelemetryController : CrudController<TelemetryDto, ICrudService<TelemetryDto>>
{
private readonly ITelemetryService telemetryService;
public AdminTelemetryController(ICrudService<TelemetryDto> service,
ITelemetryService telemetryService)
: base(service)
{
service.Includes.Add("Well");
this.telemetryService = telemetryService;
}
/// <summary>
/// Merge telemetries. No body required.
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("/merge/{idFrom}/{idTo}")]
public async Task<IActionResult> MergeTelemetriesAsync(int idFrom, int idTo, CancellationToken token = default)
{
var count = await telemetryService.MergeAsync(idFrom, idTo, token)
.ConfigureAwait(false);
return Ok(count);
}
}
}