diff --git a/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs b/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs index 39d60ea9..efa60638 100644 --- a/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs +++ b/AsbCloudWebApi/Controllers/Subsystems/SubsystemOperationTimeController.cs @@ -1,11 +1,9 @@ using AsbCloudApp.Data; using AsbCloudApp.Data.Subsystems; -using AsbCloudApp.Exceptions; using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudApp.Services.Subsystems; using AsbCloudDb.Model; -using AsbCloudInfrastructure; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; @@ -56,7 +54,6 @@ namespace AsbCloudWebApi.Controllers.Subsystems { if (!await UserHasAccesToWellAsync(request.IdWell, token)) return Forbid(); - await CustomValidate(request, token); var subsystemResult = await subsystemOperationTimeService.GetStatAsync(request, token); return Ok(subsystemResult); } @@ -133,7 +130,6 @@ namespace AsbCloudWebApi.Controllers.Subsystems { if (!await UserHasAccesToWellAsync(request.IdWell, token)) return Forbid(); - await CustomValidate(request, token); var result = await subsystemOperationTimeService.GetOperationTimeAsync(request, token); return Ok(result); @@ -155,7 +151,6 @@ namespace AsbCloudWebApi.Controllers.Subsystems { if (!await UserHasAccesToWellAsync(request.IdWell, token)) return Forbid(); - await CustomValidate(request, token); var result = await subsystemOperationTimeService.DeleteAsync(request, token); return Ok(result); } @@ -180,24 +175,5 @@ namespace AsbCloudWebApi.Controllers.Subsystems return true; return false; } - - /// - /// Валидирует запрос и бросает исключение ArgumentInvalidException - /// - /// - /// - /// - /// - private async Task CustomValidate(SubsystemOperationTimeRequest request, CancellationToken token) - { - var well = await wellService.GetOrDefaultAsync(request.IdWell, token); - if (well is not null && request.LtDate.HasValue) - { - var ltDate = request.LtDate.Value; - var utcDateRequest = ltDate.ToUtcDateTimeOffset(well.Timezone.Hours); - if (utcDateRequest.AddHours(2) > DateTime.UtcNow) - throw new ArgumentInvalidException(nameof(request.LtDate), "Запрашиваемый диапазон должен заканчиваться за 2 часа до текущего времени"); - } - } } }