diff --git a/AsbCloudApp/Exceptions/ArgumentInvalidException.cs b/AsbCloudApp/Exceptions/ArgumentInvalidException.cs
index 46057ff0..f5e3f3cd 100644
--- a/AsbCloudApp/Exceptions/ArgumentInvalidException.cs
+++ b/AsbCloudApp/Exceptions/ArgumentInvalidException.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
namespace AsbCloudApp.Exceptions
{
@@ -10,7 +11,7 @@ namespace AsbCloudApp.Exceptions
///
/// название аргумента
///
- public string[] ParamsNames { get; } = null!;
+ public IDictionary ParamsNames { get; } = null!;
///
/// конструктор
@@ -20,7 +21,9 @@ namespace AsbCloudApp.Exceptions
public ArgumentInvalidException(string paramName, string message)
: base(message)
{
- ParamsNames = new string[1] { paramName };
+ ParamsNames = new Dictionary() {
+ { paramName, new[]{ message } }
+ };
}
///
@@ -31,7 +34,9 @@ namespace AsbCloudApp.Exceptions
public ArgumentInvalidException(string[] paramsNames, string message)
: base(message)
{
- ParamsNames = paramsNames;
+ ParamsNames = new Dictionary() {
+ { string.Join(", ", paramsNames), new[]{ message } }
+ };
}
}
}
diff --git a/AsbCloudInfrastructure/Repository/DrillTestRepository.cs b/AsbCloudInfrastructure/Repository/DrillTestRepository.cs
index 4ab892a3..f5fb4ece 100644
--- a/AsbCloudInfrastructure/Repository/DrillTestRepository.cs
+++ b/AsbCloudInfrastructure/Repository/DrillTestRepository.cs
@@ -2,7 +2,6 @@
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
-using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
using Microsoft.EntityFrameworkCore;
@@ -27,6 +26,7 @@ namespace AsbCloudInfrastructure.Repository
{
var query = db.DrillTests
.Where(d => d.IdTelemetry == idTelemetry)
+ .Include(d => d.Telemetry)
.AsNoTracking();
if (request.GeDate.HasValue)
@@ -41,7 +41,7 @@ namespace AsbCloudInfrastructure.Repository
}
var entities = await query.ToListAsync(cancellationToken);
- var dtos = entities.Select(e => e.Adapt());
+ var dtos = entities.Select(e => Convert(e));
return dtos;
}
@@ -58,8 +58,7 @@ namespace AsbCloudInfrastructure.Repository
if (drillTest is null)
throw new ArgumentInvalidException(new string[] { nameof(id), nameof(idTelemetry) }, $"Drill test with id: {id} and idTelemetry: {idTelemetry} does not exist.");
- var dto = drillTest.Adapt();
- dto.TimeStampStart = dto.TimeStampStart.ToRemoteDateTime(dto.Telemetry?.TimeZone?.Hours ?? 0);
+ var dto = Convert(drillTest);
return dto;
}
@@ -72,5 +71,12 @@ namespace AsbCloudInfrastructure.Repository
var result = await db.SaveChangesAsync(token);
return result;
}
+
+ private DrillTestDto Convert(DrillTest entity)
+ {
+ var dto = entity.Adapt();
+ dto.TimeStampStart = dto.TimeStampStart.ToRemoteDateTime(dto.Telemetry?.TimeZone?.Hours ?? 0);
+ return dto;
+ }
}
}
diff --git a/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportService.cs b/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportService.cs
index 6784ad26..983d1f7c 100644
--- a/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportService.cs
+++ b/AsbCloudInfrastructure/Services/DrillTestReport/DrillTestReportService.cs
@@ -82,11 +82,11 @@ namespace AsbCloudInfrastructure.Services.DrillTestReport
reports.Add(new DrillTestReportInfoDto
{
- FileName = string.Format("Drill_test_{0}", remoteDateTime),
+ FileName = string.Format("Drill_test_{0}", dto.TimeStampStart.DateTime),
DrillDepth = (dto.Params
.Where(p => p.DepthDrillStep.HasValue)
.Sum(x => x.DepthDrillStep) ?? 0) + dto.DepthStart,
- DateTime = remoteDateTime,
+ DateTime = dto.TimeStampStart.DateTime,
Id = dto.Id,
});
}
diff --git a/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs b/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs
index 0bdf0683..3b3f052a 100644
--- a/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs
+++ b/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs
@@ -56,10 +56,7 @@ namespace AsbCloudWebApi.Middlewares
private static string MakeJsonBody(ArgumentInvalidException ex)
{
- var errors = new Dictionary() {
- { string.Join(", ", ex.ParamsNames), new[]{ ex.Message } }
- };
- var problem = new ValidationProblemDetails(errors);
+ var problem = new ValidationProblemDetails(ex.ParamsNames);
var buffer = System.Text.Json.JsonSerializer.Serialize(problem);
return buffer;
}
diff --git a/AsbCloudWebApi/Rest/DrillTest.http b/AsbCloudWebApi/Rest/DrillTest.http
index 47d7db66..a5348ead 100644
--- a/AsbCloudWebApi/Rest/DrillTest.http
+++ b/AsbCloudWebApi/Rest/DrillTest.http
@@ -13,7 +13,7 @@ Content-Type: {{contentType}}
accept: */*
{
- "id": @id,
+ "id": {{id}},
"timeStampStart": "2023-10-23T08:55:36.882Z",
"depthStart": 10,
"params": [