diff --git a/AsbCloudApp/Repositories/IDataSaubStatRepository.cs b/AsbCloudApp/Repositories/IDataSaubStatRepository.cs
index bf3d59af..b25675c7 100644
--- a/AsbCloudApp/Repositories/IDataSaubStatRepository.cs
+++ b/AsbCloudApp/Repositories/IDataSaubStatRepository.cs
@@ -1,5 +1,5 @@
using AsbCloudApp.Data;
-using AsbCloudApp.Requests;
+using AsbCloudApp.Services;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -10,7 +10,7 @@ namespace AsbCloudApp.Repositories
///
/// Репозиторий работы с данными из таблицы t_data_daub_stat
///
- public interface IDataSaubStatRepository
+ public interface IDataSaubStatRepository : ITelemetryDataEditorService
{
///
/// Получение записей по ключу телеметрии
@@ -37,13 +37,5 @@ namespace AsbCloudApp.Repositories
///
///
Task InsertRangeAsync(IEnumerable dataSaubStats, CancellationToken token);
-
- ///
- /// Удаление записей по запросу на удаление куска телеметрии
- ///
- ///
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
}
}
diff --git a/AsbCloudApp/Repositories/IDetectedOperationRepository.cs b/AsbCloudApp/Repositories/IDetectedOperationRepository.cs
index ef98b854..51a96966 100644
--- a/AsbCloudApp/Repositories/IDetectedOperationRepository.cs
+++ b/AsbCloudApp/Repositories/IDetectedOperationRepository.cs
@@ -1,18 +1,18 @@
-using System;
+using AsbCloudApp.Data;
using AsbCloudApp.Data.DetectedOperation;
using AsbCloudApp.Requests;
+using AsbCloudApp.Services;
+using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
using System.Threading;
-using AsbCloudApp.Data;
-using AsbCloudApp.Data.WellOperation;
+using System.Threading.Tasks;
namespace AsbCloudApp.Repositories;
///
/// Таблица автоматически определенных операций
///
-public interface IDetectedOperationRepository
+public interface IDetectedOperationRepository : ITelemetryDataEditorService
{
///
/// Добавление нескольких записей
@@ -21,7 +21,7 @@ public interface IDetectedOperationRepository
///
/// количество добавленных
Task InsertRangeAsync(IEnumerable dtos, CancellationToken token);
-
+
///
/// Обновить несколько записей
///
@@ -37,7 +37,7 @@ public interface IDetectedOperationRepository
///
///
Task DeleteRangeAsync(IEnumerable ids, CancellationToken token);
-
+
///
/// Получить автоматически определенные операции по телеметрии
///
@@ -60,7 +60,7 @@ public interface IDetectedOperationRepository
///
///
Task> GetLastDetectedDatesAsync(CancellationToken token);
-
+
///
/// Удалить операции
///
@@ -68,12 +68,4 @@ public interface IDetectedOperationRepository
///
///
Task DeleteAsync(DetectedOperationByTelemetryRequest request, CancellationToken token);
-
- ///
- /// Удалить операции по запросу на удаление куска телеметрии
- ///
- /// запрос
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
}
diff --git a/AsbCloudApp/Repositories/IDrillTestRepository.cs b/AsbCloudApp/Repositories/IDrillTestRepository.cs
index 50d9e631..d7b5d1b7 100644
--- a/AsbCloudApp/Repositories/IDrillTestRepository.cs
+++ b/AsbCloudApp/Repositories/IDrillTestRepository.cs
@@ -1,5 +1,6 @@
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Requests;
+using AsbCloudApp.Services;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -9,7 +10,7 @@ namespace AsbCloudApp.Repositories
///
/// репозиторий по работе с данными drill_test
///
- public interface IDrillTestRepository
+ public interface IDrillTestRepository : ITelemetryDataEditorService
{
///
/// Получить данные drill_test в соответствии с параметрами запроса
@@ -37,13 +38,5 @@ namespace AsbCloudApp.Repositories
///
///
Task SaveDataAsync(int idTelemetry, IEnumerable dtos, CancellationToken token);
-
- ///
- /// Удаление записей drill_test по запросу на удаление куска телеметрии
- ///
- ///
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
}
}
diff --git a/AsbCloudApp/Repositories/IGtrRepository.cs b/AsbCloudApp/Repositories/IGtrRepository.cs
index 8a50afd9..fcda4be2 100644
--- a/AsbCloudApp/Repositories/IGtrRepository.cs
+++ b/AsbCloudApp/Repositories/IGtrRepository.cs
@@ -5,13 +5,14 @@ using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Requests;
using AsbCloudApp.Data;
+using AsbCloudApp.Services;
namespace AsbCloudApp.Repositories
{
///
/// данные ГТИ
///
- public interface IGtrRepository
+ public interface IGtrRepository : ITelemetryDataEditorService
{
///
/// добавить данные (для панели бурильщика)
@@ -71,14 +72,5 @@ namespace AsbCloudApp.Repositories
///
///
Task GetRangeAsync(int idWell, DateTimeOffset? geDate, DateTimeOffset? leDate, CancellationToken token);
-
- ///
- /// удаление данных ГТИ по запросу на удаление куска телеметрии
- ///
- /// запрос
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
- where TType : notnull;
}
}
diff --git a/AsbCloudApp/Repositories/ILimitingParameterRepository.cs b/AsbCloudApp/Repositories/ILimitingParameterRepository.cs
index 747f72c8..dcc2725a 100644
--- a/AsbCloudApp/Repositories/ILimitingParameterRepository.cs
+++ b/AsbCloudApp/Repositories/ILimitingParameterRepository.cs
@@ -1,16 +1,16 @@
using AsbCloudApp.Data;
using AsbCloudApp.Requests;
+using AsbCloudApp.Services;
using System.Collections.Generic;
-using System.Threading.Tasks;
using System.Threading;
-using System;
+using System.Threading.Tasks;
namespace AsbCloudApp.Repositories
{
///
/// Репозиторий по ограничивающим параметрам с фильтрацией
///
- public interface ILimitingParameterRepository
+ public interface ILimitingParameterRepository : ITelemetryDataEditorService
{
///
/// Получение списка ограничивающих параметров по идентификатору скважины
@@ -30,15 +30,5 @@ namespace AsbCloudApp.Repositories
///
///
Task> GetLimitingParametersAsync(LimitingParameterRequest request, int idTelemetry, double timezoneHours, CancellationToken token);
-
- ///
- /// Удаление ограничивающих параметров по запросу на удаление куска телеметрии
- ///
- ///
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
-
-
}
}
diff --git a/AsbCloudApp/Requests/TelemetryPartDeleteRequest.cs b/AsbCloudApp/Requests/TelemetryPartDeleteRequest.cs
index 30c25994..a47d17f5 100644
--- a/AsbCloudApp/Requests/TelemetryPartDeleteRequest.cs
+++ b/AsbCloudApp/Requests/TelemetryPartDeleteRequest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Requests;
@@ -6,7 +7,7 @@ namespace AsbCloudApp.Requests;
///
/// Параметры запроса на удаление куска телеметрии
///
-public class TelemetryPartDeleteRequest
+public class TelemetryPartDeleteRequest : IValidatableObject
{
///
/// ключ телеметрии
@@ -22,4 +23,17 @@ public class TelemetryPartDeleteRequest
/// less or equal then Date
///
public DateTimeOffset? LeDate { get; set; }
+
+ ///
+ /// Валидация входящих данных
+ ///
+ ///
+ ///
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ if (IdTelemetry == 0)
+ yield return new ValidationResult($"IdTelemetry must be defined");
+ if (!GeDate.HasValue && !LeDate.HasValue)
+ yield return new ValidationResult($"GeDate or LeDate must be defined");
+ }
}
diff --git a/AsbCloudApp/Services/IMessageService.cs b/AsbCloudApp/Services/IMessageService.cs
index 15b932bb..0a6557ba 100644
--- a/AsbCloudApp/Services/IMessageService.cs
+++ b/AsbCloudApp/Services/IMessageService.cs
@@ -10,7 +10,7 @@ namespace AsbCloudApp.Services
///
/// Сервис сообщений панели оператора
///
- public interface IMessageService
+ public interface IMessageService : ITelemetryDataEditorService
{
///
/// Получить сообщения по параметрам
@@ -29,13 +29,5 @@ namespace AsbCloudApp.Services
///
Task InsertAsync(string uid, IEnumerable dtos,
CancellationToken token);
-
- ///
- /// Удаление сообщений по запросу на удаление куска телеметрии
- ///
- /// запрос
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
}
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/ITelemetryDataEditorService.cs b/AsbCloudApp/Services/ITelemetryDataEditorService.cs
index 59493a4e..d9d5df24 100644
--- a/AsbCloudApp/Services/ITelemetryDataEditorService.cs
+++ b/AsbCloudApp/Services/ITelemetryDataEditorService.cs
@@ -15,5 +15,5 @@ public interface ITelemetryDataEditorService
///
///
///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
+ Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
}
diff --git a/AsbCloudApp/Services/ITelemetryDataService.cs b/AsbCloudApp/Services/ITelemetryDataService.cs
index dcfdcce4..f9e3c4d7 100644
--- a/AsbCloudApp/Services/ITelemetryDataService.cs
+++ b/AsbCloudApp/Services/ITelemetryDataService.cs
@@ -11,7 +11,7 @@ namespace AsbCloudApp.Services
/// сервис данных тех. процесса
///
///
- public interface ITelemetryDataService where TDto : ITelemetryData
+ public interface ITelemetryDataService : ITelemetryDataEditorService where TDto : ITelemetryData
{
///
@@ -70,14 +70,5 @@ namespace AsbCloudApp.Services
///
///
Task UpdateDataAsync(string uid, IEnumerable dtos, CancellationToken token);
-
- ///
- /// удалить данные по запросу
- ///
- /// запрос
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
-
}
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/IWitsRepository.cs b/AsbCloudApp/Services/IWitsRepository.cs
index f49832af..e6b409c1 100644
--- a/AsbCloudApp/Services/IWitsRepository.cs
+++ b/AsbCloudApp/Services/IWitsRepository.cs
@@ -10,7 +10,7 @@ namespace AsbCloudApp.Services
///
/// The wits record repository.
///
- public interface IWitsRecordRepository
+ public interface IWitsRecordRepository : ITelemetryDataEditorService
where TDto : ITelemetryData
{
///
@@ -46,13 +46,5 @@ namespace AsbCloudApp.Services
/// The token.
/// A Task.
Task<(DateTime begin, DateTime end, int count)?> GetStatAsync(int idTelemetry, CancellationToken token);
-
- ///
- /// Удалить записи по запросу на удаление куска телеметрии
- ///
- ///
- ///
- ///
- Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token);
}
}
\ No newline at end of file
diff --git a/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs b/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs
index 1d517563..d5159bf6 100644
--- a/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs
+++ b/AsbCloudInfrastructure/Repository/DataSaubStatRepository.cs
@@ -88,16 +88,16 @@ namespace AsbCloudInfrastructure.Repository
var query = db.Set()
.Where(o => o.IdTelemetry == request.IdTelemetry);
- if (request.GeDate is not null)
- {
- var geDate = request.GeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateStart <= geDate);
- }
-
if (request.LeDate is not null)
{
var leDate = request.LeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateEnd >= leDate);
+ query = query.Where(o => o.DateStart <= leDate);
+ }
+
+ if (request.GeDate is not null)
+ {
+ var geDate = request.GeDate.Value.ToUniversalTime();
+ query = query.Where(o => o.DateEnd >= geDate);
}
return query;
diff --git a/AsbCloudInfrastructure/Repository/DetectedOperationRepository.cs b/AsbCloudInfrastructure/Repository/DetectedOperationRepository.cs
index da148ab7..10889a3d 100644
--- a/AsbCloudInfrastructure/Repository/DetectedOperationRepository.cs
+++ b/AsbCloudInfrastructure/Repository/DetectedOperationRepository.cs
@@ -15,7 +15,8 @@ using AsbCloudApp.Data;
namespace AsbCloudInfrastructure.Repository;
-public class DetectedOperationRepository : CrudRepositoryBase, IDetectedOperationRepository
+public class DetectedOperationRepository
+ : CrudRepositoryBase, IDetectedOperationRepository
{
private readonly ITelemetryService telemetryService;
@@ -125,16 +126,16 @@ public class DetectedOperationRepository : CrudRepositoryBase()
.Where(o => o.IdTelemetry == request.IdTelemetry);
- if (request.GeDate is not null)
- {
- var geDate = request.GeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateStart <= geDate);
- }
-
if (request.LeDate is not null)
{
var leDate = request.LeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateEnd >= leDate);
+ query = query.Where(o => o.DateStart <= leDate);
+ }
+
+ if (request.GeDate is not null)
+ {
+ var geDate = request.GeDate.Value.ToUniversalTime();
+ query = query.Where(o => o.DateEnd >= geDate);
}
return query;
diff --git a/AsbCloudInfrastructure/Repository/DrillTestRepository.cs b/AsbCloudInfrastructure/Repository/DrillTestRepository.cs
index e620ca6f..0c28e6f3 100644
--- a/AsbCloudInfrastructure/Repository/DrillTestRepository.cs
+++ b/AsbCloudInfrastructure/Repository/DrillTestRepository.cs
@@ -85,21 +85,22 @@ namespace AsbCloudInfrastructure.Repository
return dto;
}
+ //TODO: . .
private IQueryable BuildQuery(TelemetryPartDeleteRequest request)
{
var query = db.Set()
.Where(o => o.IdTelemetry == request.IdTelemetry);
- if (request.GeDate is not null)
- {
- var geDate = request.GeDate.Value.ToUniversalTime();
- query = query.Where(o => o.TimeStampStart <= geDate);
- }
-
if (request.LeDate is not null)
{
var leDate = request.LeDate.Value.ToUniversalTime();
- query = query.Where(o => o.TimeStampStart >= leDate);
+ query = query.Where(o => o.TimeStampStart <= leDate);
+ }
+
+ if (request.GeDate is not null)
+ {
+ var geDate = request.GeDate.Value.ToUniversalTime();
+ query = query.Where(o => o.TimeStampStart >= geDate);
}
return query;
diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs
index 451387ae..54b19e6b 100644
--- a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs
+++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs
@@ -446,32 +446,29 @@ namespace AsbCloudInfrastructure.Repository
{
var query = db.Set().Where(i => i.IdTelemetry == request.IdTelemetry);
- if (request.GeDate is not null)
- {
- var geDate = request.GeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateTime <= geDate);
- }
-
if (request.LeDate is not null)
{
var leDate = request.LeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateTime >= leDate);
+ query = query.Where(o => o.DateTime <= leDate);
+ }
+
+ if (request.GeDate is not null)
+ {
+ var geDate = request.GeDate.Value.ToUniversalTime();
+ query = query.Where(o => o.DateTime >= geDate);
}
return query;
}
- public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
- where TType : notnull
+ public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
{
- if (typeof(TType) == typeof(float))
- return await DeleteAsync(request, token);
- if (typeof(TType) == typeof(int))
- return await DeleteAsync(request, token);
- if (typeof(TType) == typeof(string))
- return await DeleteAsync(request, token);
+ var result = 0;
+ result += await DeleteAsync(request, token);
+ result += await DeleteAsync(request, token);
+ result += await DeleteAsync(request, token);
- return await Task.FromResult(0);
+ return result;
}
private async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
diff --git a/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs b/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs
index bf5957a6..858558df 100644
--- a/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs
+++ b/AsbCloudInfrastructure/Repository/LimitingParameterRepository.cs
@@ -87,16 +87,16 @@ namespace AsbCloudInfrastructure.Repository
var query = context.Set()
.Where(o => o.IdTelemetry == request.IdTelemetry);
- if (request.GeDate is not null)
- {
- var geDate = request.GeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateStart <= geDate);
- }
-
if (request.LeDate is not null)
{
var leDate = request.LeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateEnd >= leDate);
+ query = query.Where(o => o.DateStart <= leDate);
+ }
+
+ if (request.GeDate is not null)
+ {
+ var geDate = request.GeDate.Value.ToUniversalTime();
+ query = query.Where(o => o.DateEnd >= geDate);
}
return query;
diff --git a/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs b/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs
index 7239aa9c..46ea461a 100644
--- a/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs
+++ b/AsbCloudInfrastructure/Repository/WitsRecordRepository.cs
@@ -64,16 +64,16 @@ namespace AsbCloudInfrastructure.Repository
var query = db.Set()
.Where(o => o.IdTelemetry == request.IdTelemetry);
- if (request.GeDate is not null)
- {
- var geDate = request.GeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateTime <= geDate);
- }
-
if (request.LeDate is not null)
{
var leDate = request.LeDate.Value.ToUniversalTime();
- query = query.Where(o => o.DateTime >= leDate);
+ query = query.Where(o => o.DateTime <= leDate);
+ }
+
+ if (request.GeDate is not null)
+ {
+ var geDate = request.GeDate.Value.ToUniversalTime();
+ query = query.Where(o => o.DateTime >= geDate);
}
return query;
diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataEditorService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataEditorService.cs
index eebe6706..bc80b641 100644
--- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataEditorService.cs
+++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataEditorService.cs
@@ -13,20 +13,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
///
public class TelemetryDataEditorService : ITelemetryDataEditorService
{
- private readonly ITelemetryDataSaubService dataSaubService;
- private readonly ITelemetryDataService dataSpinService;
- private readonly IDataSaubStatRepository dataSaubStatRepository;
- private readonly IMessageService messageService;
- private readonly IDrillTestRepository drillTestRepository;
- private readonly ILimitingParameterRepository limitingParameterRepository;
- private readonly IDetectedOperationRepository detectedOperationRepository;
- private readonly IWitsRecordRepository witsRecord1Repository;
- private readonly IWitsRecordRepository witsRecord7Repository;
- private readonly IWitsRecordRepository witsRecord8Repository;
- private readonly IWitsRecordRepository witsRecord50Repository;
- private readonly IWitsRecordRepository witsRecord60Repository;
- private readonly IWitsRecordRepository witsRecord61Repository;
- private readonly IGtrRepository gtrRepository;
+ private readonly ITelemetryDataEditorService[] repositories;
///
///
@@ -62,40 +49,34 @@ namespace AsbCloudInfrastructure.Services.SAUB
IGtrRepository gtrRepository
)
{
- this.dataSaubService = dataSaubService;
- this.dataSpinService = dataSpinService;
- this.dataSaubStatRepository = dataSaubStatRepository;
- this.messageService = messageService;
- this.drillTestRepository = drillTestRepository;
- this.limitingParameterRepository = limitingParameterRepository;
- this.detectedOperationRepository = detectedOperationRepository;
- this.witsRecord1Repository = witsRecord1Repository;
- this.witsRecord7Repository = witsRecord7Repository;
- this.witsRecord8Repository = witsRecord8Repository;
- this.witsRecord50Repository = witsRecord50Repository;
- this.witsRecord60Repository = witsRecord60Repository;
- this.witsRecord61Repository = witsRecord61Repository;
- this.gtrRepository = gtrRepository;
+ repositories =
+ [
+ dataSaubService,
+ dataSpinService,
+ dataSaubStatRepository,
+ messageService,
+ drillTestRepository,
+ limitingParameterRepository,
+ detectedOperationRepository,
+ witsRecord1Repository,
+ witsRecord7Repository,
+ witsRecord8Repository,
+ witsRecord50Repository,
+ witsRecord60Repository,
+ witsRecord61Repository,
+ gtrRepository,
+ ];
}
- public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
+ public async Task DeleteAsync(TelemetryPartDeleteRequest request, CancellationToken token)
{
- await dataSaubService.DeleteAsync(request, token);
- await dataSpinService.DeleteAsync(request, token);
- await dataSaubStatRepository.DeleteAsync(request, token);
- await messageService.DeleteAsync(request, token);
- await drillTestRepository.DeleteAsync(request, token);
- await limitingParameterRepository.DeleteAsync(request, token);
- await detectedOperationRepository.DeleteAsync(request, token);
- await witsRecord1Repository.DeleteAsync(request, token);
- await witsRecord7Repository.DeleteAsync(request, token);
- await witsRecord8Repository.DeleteAsync(request, token);
- await witsRecord50Repository.DeleteAsync(request, token);
- await witsRecord60Repository.DeleteAsync(request, token);
- await witsRecord61Repository.DeleteAsync(request, token);
- await gtrRepository.DeleteAsync(request, token);
- await gtrRepository.DeleteAsync(request, token);
- await gtrRepository.DeleteAsync(request, token);
+ int result = 0;
+ foreach (var repository in repositories)
+ {
+ result += await repository.DeleteAsync(request, token);
+ }
+
+ return result;
}
}
}
diff --git a/AsbCloudWebApi/Controllers/AdminTelemetryController.cs b/AsbCloudWebApi/Controllers/AdminTelemetryController.cs
index d259f94f..2e9dad91 100644
--- a/AsbCloudWebApi/Controllers/AdminTelemetryController.cs
+++ b/AsbCloudWebApi/Controllers/AdminTelemetryController.cs
@@ -2,6 +2,7 @@ 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;
@@ -43,29 +44,20 @@ namespace AsbCloudWebApi.Controllers
}
///
- /// Удаление куска телеметрии
+ /// Удаление куска телеметрии по запросу
///
- /// ключ телеметрии
- /// начало интервала удаления
- /// конец интервала удаления
+ /// запрос
///
///
- [HttpDelete("/part/{telemetryId}")]
+ [HttpDelete("/part")]
[Permission]
- public async Task DeleteAsync(int telemetryId,
- DateTimeOffset? gDate,
- DateTimeOffset? lDate,
- CancellationToken token)
+ [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
+ [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
+ public async Task DeleteAsync([FromQuery] TelemetryPartDeleteRequest request,CancellationToken token)
{
- var request = new TelemetryPartDeleteRequest()
- {
- IdTelemetry = telemetryId,
- GeDate = gDate,
- LeDate = lDate
- };
- if(gDate.HasValue || lDate.HasValue)
- await telemetryEditorService.DeleteAsync(request, token);
- return Ok();
+ var result = await telemetryEditorService.DeleteAsync(request, token);
+
+ return Ok(result);
}
}
}