diff --git a/Persistence.Repository/Repositories/ChangeLogRepository.cs b/Persistence.Repository/Repositories/ChangeLogRepository.cs index 4b5d901..ac00e05 100644 --- a/Persistence.Repository/Repositories/ChangeLogRepository.cs +++ b/Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -101,34 +101,29 @@ public class ChangeLogRepository : IChangeLogRepository var result = 0; using var transaction = await db.Database.BeginTransactionAsync(token); - try + + foreach (var dto in dtos) { - foreach (var dto in dtos) + var updatedEntity = updatedEntities.GetValueOrDefault(dto.Id); + if (updatedEntity is null) { - var updatedEntity = updatedEntities.GetValueOrDefault(dto.Id); - if (updatedEntity is null) - { - throw new ArgumentException($"Entity with id = {dto.Id} doesn't exist in Db", nameof(dto)); - } - - var newEntity = CreateEntityFromDto(idEditor, updatedEntity.IdDiscriminator, dto); - dbSet.Add(newEntity); - - updatedEntity.IdNext = newEntity.Id; - updatedEntity.Obsolete = DateTimeOffset.UtcNow; - updatedEntity.IdEditor = idEditor; + throw new ArgumentException($"Entity with id = {dto.Id} doesn't exist in Db", nameof(dto)); } - result = await db.SaveChangesAsync(token); - await transaction.CommitAsync(token); + var newEntity = CreateEntityFromDto(idEditor, updatedEntity.IdDiscriminator, dto); + dbSet.Add(newEntity); - return result; - } - catch - { - await transaction.RollbackAsync(token); - throw; + updatedEntity.IdNext = newEntity.Id; + updatedEntity.Obsolete = DateTimeOffset.UtcNow; + updatedEntity.IdEditor = idEditor; } + + result = await db.SaveChangesAsync(token); + await transaction.CommitAsync(token); + + return result; + + } public async Task> GetByDate(