Merge branch 'dev' into #28855145/tvd-graph-from-start-date

This commit is contained in:
on.nemtina 2024-08-13 10:19:37 +05:00
commit 080224bbbd
2 changed files with 20 additions and 3 deletions

View File

@ -35,7 +35,7 @@ public class ContactDto : IId
/// <summary>
/// Email
/// </summary>
[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; }
/// <summary>

View File

@ -117,6 +117,22 @@ public abstract class ChangeLogRepositoryAbstract<TEntity, TDto, TRequest> : ICh
}
public async Task<int> InsertRange(int idUser, IEnumerable<TDto> 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<int> InsertRangeWithoutTransaction(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
{
var result = 0;
if (dtos.Any())
@ -138,6 +154,7 @@ public abstract class ChangeLogRepositoryAbstract<TEntity, TDto, TRequest> : ICh
result += await SaveChangesWithExceptionHandling(token);
}
return result;
}
@ -248,7 +265,7 @@ public abstract class ChangeLogRepositoryAbstract<TEntity, TDto, TRequest> : 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;