refactor
This commit is contained in:
parent
e282e2ece3
commit
84457413b2
20 changed files with 224 additions and 246 deletions
|
@ -0,0 +1,23 @@
|
|||
using Femto.Modules.Auth.Data;
|
||||
using MediatR;
|
||||
|
||||
namespace Femto.Modules.Auth.Infrastructure;
|
||||
|
||||
internal class SaveChangesPipelineBehaviour<TRequest, TResponse>(AuthContext context)
|
||||
: IPipelineBehavior<TRequest, TResponse>
|
||||
where TRequest : notnull
|
||||
{
|
||||
public async Task<TResponse> Handle(
|
||||
TRequest request,
|
||||
RequestHandlerDelegate<TResponse> next,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var response = await next(cancellationToken);
|
||||
|
||||
if (context.ChangeTracker.HasChanges())
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue