Egyéb javítások
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user