diff --git a/AsbCloudApp/Data/User/ContactDto.cs b/AsbCloudApp/Data/User/ContactDto.cs index dd6b3212..8445d801 100644 --- a/AsbCloudApp/Data/User/ContactDto.cs +++ b/AsbCloudApp/Data/User/ContactDto.cs @@ -35,7 +35,7 @@ public class ContactDto : IId /// /// Email /// - [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")] + [RegularExpression(@"^[a-zA-Z0-9_\-\.]{3,128}@[a-zA-Z0-9_\-\.]{2,128}\.[a-zA-Z]{1,32}$", ErrorMessage = "Некорректный email")] public string? Email { get; set; } /// diff --git a/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs b/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs index 157b204d..c47ebd05 100644 --- a/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs +++ b/AsbCloudInfrastructure/Repository/ChangeLogRepositoryAbstract.cs @@ -117,6 +117,22 @@ public abstract class ChangeLogRepositoryAbstract : ICh } public async Task InsertRange(int idUser, IEnumerable dtos, CancellationToken token) + { + using var transaction = db.Database.BeginTransaction(); + try + { + var result = await InsertRangeWithoutTransaction(idUser, dtos, token); + await transaction.CommitAsync(token); + return result; + } + catch + { + await transaction.RollbackAsync(token); + throw; + } + } + + private async Task InsertRangeWithoutTransaction(int idUser, IEnumerable dtos, CancellationToken token) { var result = 0; if (dtos.Any()) @@ -138,7 +154,8 @@ public abstract class ChangeLogRepositoryAbstract : ICh result += await SaveChangesWithExceptionHandling(token); } - return result; + + return result; } public async Task UpdateRange(int idUser, IEnumerable dtos, CancellationToken token) @@ -248,7 +265,7 @@ public abstract class ChangeLogRepositoryAbstract : ICh try { result += await Clear(idUser, request, token); - result += await InsertRange(idUser, dtos, token); + result += await InsertRangeWithoutTransaction(idUser, dtos, token); await transaction.CommitAsync(token); return result;