From cfba6143deee844e57d179c19d51b3c0fe66d5d5 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Mon, 12 Feb 2024 13:58:02 +0500 Subject: [PATCH] Fixes by review --- AsbCloudApp/Data/SimpleTimezoneDto.cs | 12 ++++++------ AsbCloudApp/Exceptions/ArgumentInvalidException.cs | 1 + AsbCloudApp/Repositories/IWellOperationRepository.cs | 2 ++ AsbCloudDb/EFExtensionsExceptionHandling.cs | 1 + .../Repository/ChangeLogRepositoryAbstract.cs | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/AsbCloudApp/Data/SimpleTimezoneDto.cs b/AsbCloudApp/Data/SimpleTimezoneDto.cs index e878bacf..5d2e1f8f 100644 --- a/AsbCloudApp/Data/SimpleTimezoneDto.cs +++ b/AsbCloudApp/Data/SimpleTimezoneDto.cs @@ -3,29 +3,29 @@ using System; namespace AsbCloudApp.Data { /// - /// + /// временная зона /// public class SimpleTimezoneDto { /// - /// UTC + /// смещение в часах относительно UTC /// public double Hours { get; set; } /// - /// + /// идентификатор часовой зоны /// public string? TimezoneId { get; set; } /// - /// + /// запрет на переопределение /// public bool IsOverride { get; set; } /// - /// + /// Смещение часового пояса /// - public TimeSpan Offset { get => TimeSpan.FromHours(Hours); } + public TimeSpan Offset => TimeSpan.FromHours(Hours); /// public override bool Equals(object? obj) diff --git a/AsbCloudApp/Exceptions/ArgumentInvalidException.cs b/AsbCloudApp/Exceptions/ArgumentInvalidException.cs index 5db63313..641f18ce 100644 --- a/AsbCloudApp/Exceptions/ArgumentInvalidException.cs +++ b/AsbCloudApp/Exceptions/ArgumentInvalidException.cs @@ -14,6 +14,7 @@ namespace AsbCloudApp.Exceptions /// public IDictionary ErrorState { get; } = null!; + // TODO: swap arguments, inherit from ArgumentException /// /// конструктор /// diff --git a/AsbCloudApp/Repositories/IWellOperationRepository.cs b/AsbCloudApp/Repositories/IWellOperationRepository.cs index 8cb313ac..ff3bfb8e 100644 --- a/AsbCloudApp/Repositories/IWellOperationRepository.cs +++ b/AsbCloudApp/Repositories/IWellOperationRepository.cs @@ -13,10 +13,12 @@ namespace AsbCloudApp.Repositories /// public interface IWellOperationRepository { + //TODO: replace all references /// /// список названий операций /// /// + [Obsolete("use IWellOperationCategoryRepository.GetCategories(bool includeParents)")] IEnumerable GetCategories(bool includeParents); /// diff --git a/AsbCloudDb/EFExtensionsExceptionHandling.cs b/AsbCloudDb/EFExtensionsExceptionHandling.cs index 77b8fe07..aa1996b5 100644 --- a/AsbCloudDb/EFExtensionsExceptionHandling.cs +++ b/AsbCloudDb/EFExtensionsExceptionHandling.cs @@ -27,6 +27,7 @@ namespace AsbCloudDb private static void TryConvertPostgresExceptionToValidateException(PostgresException pgException) { if (pgException.SqlState == PostgresErrorCodes.ForeignKeyViolation) + // TODO: replace ArgumentException by new Exception throw new ArgumentException(pgException.Message + "\r\n" + pgException.Detail, "dtos"); } } diff --git a/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs b/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs index ba32907c..f9265ba8 100644 --- a/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs +++ b/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs @@ -145,7 +145,7 @@ public abstract class ChangeLogRepositoryAbstract : ICh public async Task ClearAndInsertRange(int idUser, TRequest request, IEnumerable dtos, CancellationToken token) { var result = 0; - var transaction = await db.Database.BeginTransactionAsync(token); + using var transaction = await db.Database.BeginTransactionAsync(token); result += await Clear(idUser, request, token); result += await InsertRange(idUser, dtos, token); await transaction.CommitAsync(token);