mirror of https://github.com/abpframework/abp
Merge pull request #14399 from abpframework/auto-merge/rel-6-0/1416
Merge branch dev with rel-6.0pull/14130/head^2
commit
a8f0692a70
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.Users;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
|
||||
|
||||
public class ExceptionHandingUnitOfWork : UnitOfWork
|
||||
{
|
||||
public ExceptionHandingUnitOfWork(
|
||||
IServiceProvider serviceProvider,
|
||||
IUnitOfWorkEventPublisher unitOfWorkEventPublisher,
|
||||
IOptions<AbpUnitOfWorkDefaultOptions> options)
|
||||
: base(serviceProvider, unitOfWorkEventPublisher, options)
|
||||
{
|
||||
|
||||
}
|
||||
public async override Task SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (ServiceProvider.GetRequiredService<ICurrentUser>().Id == Guid.Empty)
|
||||
{
|
||||
throw new AbpDbConcurrencyException();
|
||||
}
|
||||
|
||||
await base.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue