ChangeLogRepositoryAbstract nit

This commit is contained in:
ngfrolov 2024-02-16 15:38:27 +05:00
parent 9d6fa75a01
commit b121310819
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 26 additions and 26 deletions

View File

@ -80,31 +80,31 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
}
using var transaction = db.Database.BeginTransaction();
foreach (var entity in entitiesToDelete)
{
entity.IdState = ChangeLogAbstract.IdStateReplaced;
entity.Obsolete = updateTime;
entity.IdEditor = idUser;
}
result += await db.SaveChangesAsync(token);
var entitiesNew = dtos.Select(Convert);
foreach (var entity in entitiesNew)
{
entity.IdPrevious = entity.Id;
entity.Id = default;
entity.Creation = updateTime;
entity.IdAuthor = idUser;
entity.Obsolete = null;
entity.IdEditor = null;
entity.IdState = ChangeLogAbstract.IdStateActual;
dbSet.Add(entity);
}
result += await SaveChangesWithExceptionHandling(token);
try
{
foreach (var entity in entitiesToDelete)
{
entity.IdState = ChangeLogAbstract.IdStateReplaced;
entity.Obsolete = updateTime;
entity.IdEditor = idUser;
}
result += await db.SaveChangesAsync(token);
var entitiesNew = dtos.Select(Convert);
foreach (var entity in entitiesNew)
{
entity.IdPrevious = entity.Id;
entity.Id = default;
entity.Creation = updateTime;
entity.IdAuthor = idUser;
entity.Obsolete = null;
entity.IdEditor = null;
entity.IdState = ChangeLogAbstract.IdStateActual;
dbSet.Add(entity);
}
result += await SaveChangesWithExceptionHandling(token);
await transaction.CommitAsync(token);
return result;
}
@ -153,10 +153,11 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
{
var result = 0;
using var transaction = await db.Database.BeginTransactionAsync(token);
result += await Clear(idUser, request, token);
result += await InsertRange(idUser, dtos, token);
try
{
result += await Clear(idUser, request, token);
result += await InsertRange(idUser, dtos, token);
await transaction.CommitAsync(token);
return result;
}

View File

@ -12,7 +12,6 @@ public abstract class ProcessMapPlanParser<TDto> : ParserExcelService<TDto>
protected static int? GetIdMode(string? modeName) =>
modeName?.Trim().ToLower() switch
{
"ручной" => 0,
"ротор" => 1,
"слайд" => 2,
_ => null