init
This commit is contained in:
commit
ab2e20f7e1
72 changed files with 2000 additions and 0 deletions
|
@ -0,0 +1,23 @@
|
|||
using Femto.Modules.Media.Data;
|
||||
using MediatR;
|
||||
|
||||
namespace Femto.Modules.Media.Infrastructure.PipelineBehaviours;
|
||||
|
||||
/// <summary>
|
||||
/// automatically call unit of work after all requuests
|
||||
/// </summary>
|
||||
internal class SaveChangesPipelineBehaviour<TRequest, TResponse>(MediaContext 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