From 6e55d5b542f64496049e63dab3417eb74fb5ae9b Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 31 Jan 2024 11:15:21 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B3=D0=B0=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20/=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=B2=D0=BE=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8:=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BE=D0=BA=20=D0=BF=D0=BE=20name=20=D0=B2=D0=BD=D1=82=D1=83?= =?UTF-8?q?=D1=80=D0=B8=20=20ValidationBadRequest=20+=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=20=D0=BA=D0=BE=D0=B4,=20=D0=BA=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=8B=D0=B9=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=B9=20=D0=BE=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=20=D0=BA=D0=BE=D0=BD=D0=B5?= =?UTF-8?q?=D1=86=20=D0=BF=D1=80=D0=B5=D0=B4=D1=8B=D0=B4=D1=83=D1=89=D0=B5?= =?UTF-8?q?=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/WellOperationRepository.cs | 12 ++++++------ AsbCloudWebApi/Extentions.cs | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs index 208e94ac..ea9a6975 100644 --- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs @@ -383,12 +383,12 @@ public class WellOperationRepository : IWellOperationRepository new[] { nameof(wellOperationDtos) }); } - if (previousDateEnd > currentDateStart) - { - yield return new ValidationResult( - "Предыдущая операция не завершена", - new[] { nameof(wellOperationDtos) }); - } + //if (previousDateEnd > currentDateStart) + //{ + // yield return new ValidationResult( + // "Предыдущая операция не завершена", + // new[] { nameof(wellOperationDtos) }); + //} previous = current; } diff --git a/AsbCloudWebApi/Extentions.cs b/AsbCloudWebApi/Extentions.cs index 5659292c..7299fae5 100644 --- a/AsbCloudWebApi/Extentions.cs +++ b/AsbCloudWebApi/Extentions.cs @@ -70,8 +70,10 @@ namespace Microsoft.AspNetCore.Mvc public static BadRequestObjectResult ValidationBadRequest(this ControllerBase controller, IEnumerable validationResults) { var errors = validationResults - .SelectMany(e => e.MemberNames.Select(name=> new { name, e.ErrorMessage })) - .ToDictionary(e => e.name, e => new[] { e.ErrorMessage ?? string.Empty }); + .SelectMany(e => e.MemberNames.Select(name => new { name, e.ErrorMessage })) + .GroupBy(e => e.name) + .ToDictionary(e => e.Key, e => e.Select(el => el.ErrorMessage ?? string.Empty).ToArray()); + var problem = new ValidationProblemDetails(errors); return controller.BadRequest(problem); }