Egyéb javítások

This commit is contained in:
2025-03-24 14:01:58 +01:00
parent d55dee91e9
commit 50a7eb5521
8 changed files with 85 additions and 17 deletions
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,14 +21,13 @@ namespace WorkFlowCheck.BL.Services
_dbContext = dbContext;
}
public async Task<string> GenerateNextNumberAsync(int templateId, DateTime? baseDate = null)
public async Task<string> GenerateNextNumberAsync(int templateId, IDbContextTransaction transaction, DateTime? baseDate = null)
{
var semaphore = GetOrCreateSemaphore(templateId);
await semaphore.WaitAsync();
try
{
using var transaction = await _dbContext.Database.BeginTransactionAsync();
var template = await _dbContext.Set<NumberGeneratorTemplate>()
.FirstOrDefaultAsync(t => t.Id == templateId);
@@ -60,13 +60,10 @@ namespace WorkFlowCheck.BL.Services
templateDate.LastGeneratedNumber = result;
await _dbContext.SaveChangesAsync();
await transaction.CommitAsync();
return result;
}
catch
{
await _dbContext.Database.RollbackTransactionAsync();
throw;
}
finally