-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTransactUsersService.cs
More file actions
48 lines (34 loc) · 1021 Bytes
/
TransactUsersService.cs
File metadata and controls
48 lines (34 loc) · 1021 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
37
38
39
40
41
42
43
44
45
46
47
48
using System.Data;
using System.Threading.Tasks;
using Simplify.Examples.Repository.Domain.Location;
namespace Simplify.Examples.Repository.Domain.Accounts;
public class TransactUsersService : IUsersService
{
private readonly IUsersService _baseService;
private readonly IExampleUnitOfWork _unitOfWork;
public TransactUsersService(IUsersService baseService, IExampleUnitOfWork unitOfWork)
{
_baseService = baseService;
_unitOfWork = unitOfWork;
}
public async Task<int> CreateUserAsync(IUser user)
{
_unitOfWork.BeginTransaction();
var result = await _baseService.CreateUserAsync(user);
await _unitOfWork.CommitAsync();
return result;
}
public IUser GetUser(string userName)
{
_unitOfWork.BeginTransaction(IsolationLevel.ReadUncommitted);
var item = _baseService.GetUser(userName);
_unitOfWork.Commit();
return item;
}
public void SetUserCity(IUser user, ICity city)
{
_unitOfWork.BeginTransaction();
_baseService.SetUserCity(user, city);
_unitOfWork.Commit();
}
}