-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitOfWork.cs
More file actions
36 lines (28 loc) · 1003 Bytes
/
UnitOfWork.cs
File metadata and controls
36 lines (28 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Application;
using Infrastructure.IdentityDb;
namespace Infrastructure
{
public sealed class UnitOfWork : IUnitOfWork
{
private readonly IdentityContext _context;
public UnitOfWork(IdentityContext context)
{
_context = context;
Clients = new ClientRepository(_context);
Users = new UserRepository(_context);
}
public IClientRepository Clients { get; private set; }
public IUserRepository Users { get; private set; }
public async Task SaveChangesAsync(CancellationToken cancellationToken = default)
=> await SaveChangesAsync(hasChanges: true, cancellationToken);
public async Task SaveChangesAsync(bool hasChanges, CancellationToken cancellationToken = default)
{
if (hasChanges)
await _context.SaveChangesAsync(cancellationToken);
}
public void Dispose()
{
_context.Dispose();
}
}
}