Skip to content

Commit

Permalink
feat(efcore): 更新受 #215 更改影响的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
gmf520 committed Mar 19, 2021
1 parent 51fdbc0 commit 78ea8fd
Show file tree
Hide file tree
Showing 27 changed files with 464 additions and 1,616 deletions.
24 changes: 12 additions & 12 deletions samples/web/Liuliu.Demo.Web/Controllers/IdentityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ public async Task<AjaxResult> Login(LoginDto dto)
dto.Ip = HttpContext.GetClientIp();
dto.UserAgent = Request.Headers["User-Agent"].FirstOrDefault();

IUnitOfWork unitOfWork = HttpContext.RequestServices.GetUnitOfWork(true);
OperationResult<User> result = await _identityContract.Login(dto);
IUnitOfWorkManager unitOfWorkManager = HttpContext.RequestServices.GetRequiredService<IUnitOfWorkManager>();
#if NET5_0
await unitOfWorkManager.CommitAsync();
await unitOfWork.CommitAsync();
#else
unitOfWorkManager.Commit();
unitOfWork.Commit();
#endif

if (!result.Succeeded)
Expand Down Expand Up @@ -223,12 +223,12 @@ public async Task<AjaxResult> Token(TokenDto dto)
UserAgent = Request.Headers["User-Agent"].FirstOrDefault()
};

IUnitOfWork unitOfWork = HttpContext.RequestServices.GetUnitOfWork(true);
OperationResult<User> result = await _identityContract.Login(loginDto);
IUnitOfWorkManager unitOfWorkManager = HttpContext.RequestServices.GetRequiredService<IUnitOfWorkManager>();
#if NET5_0
await unitOfWorkManager.CommitAsync();
await unitOfWork.CommitAsync();
#else
unitOfWorkManager.Commit();
unitOfWork.Commit();
#endif
if (!result.Succeeded)
{
Expand Down Expand Up @@ -338,12 +338,12 @@ public PageData<UserLoginOutputDto> ReadOAuth2([FromServices] IFilterService fil
public async Task<AjaxResult> LoginBind(UserLoginInfoEx loginInfo)
{
loginInfo.RegisterIp = HttpContext.GetClientIp();
IUnitOfWork unitOfWork = HttpContext.RequestServices.GetUnitOfWork(true);
OperationResult<User> result = await _identityContract.LoginBind(loginInfo);
IUnitOfWorkManager unitOfWorkManager = HttpContext.RequestServices.GetRequiredService<IUnitOfWorkManager>();
#if NET5_0
await unitOfWorkManager.CommitAsync();
await unitOfWork.CommitAsync();
#else
unitOfWorkManager.Commit();
unitOfWork.Commit();
#endif
if (!result.Succeeded)
{
Expand All @@ -364,12 +364,12 @@ public async Task<AjaxResult> LoginBind(UserLoginInfoEx loginInfo)
public async Task<AjaxResult> LoginOneKey(UserLoginInfoEx loginInfo)
{
loginInfo.RegisterIp = HttpContext.GetClientIp();
IUnitOfWork unitOfWork = HttpContext.RequestServices.GetUnitOfWork(true);
OperationResult<User> result = await _identityContract.LoginOneKey(loginInfo.ProviderKey);
IUnitOfWorkManager unitOfWorkManager = HttpContext.RequestServices.GetRequiredService<IUnitOfWorkManager>();
#if NET5_0
await unitOfWorkManager.CommitAsync();
await unitOfWork.CommitAsync();
#else
unitOfWorkManager.Commit();
unitOfWork.Commit();
#endif

if (!result.Succeeded)
Expand Down
6 changes: 3 additions & 3 deletions samples/web/Liuliu.Demo.Web/Hangfire/HangfireJobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public async Task<string> LockUser2()
User user2 = await userManager.FindByIdAsync("2");
list.Add($"user2.IsLocked: {user2.IsLocked}");
user2.IsLocked = !user2.IsLocked;
IUnitOfWork unitOfWork = _provider.GetUnitOfWork(true);
await userManager.UpdateAsync(user2);
IUnitOfWorkManager unitOfWorkManager = _provider.GetService<IUnitOfWorkManager>();
#if NET5_0
await unitOfWorkManager.CommitAsync();
await unitOfWork.CommitAsync();
#else
unitOfWorkManager.Commit();
unitOfWork.Commit();
#endif
user2 = await userManager.FindByIdAsync("2");
list.Add($"user2.IsLocked: {user2.IsLocked}");
Expand Down
6 changes: 3 additions & 3 deletions samples/web/Liuliu.Demo.WebApi/Hangfire/HangfireJobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public async Task<string> LockUser2()
list.Add($"user2.IsLocked: {user2.IsLocked}");
user2.IsLocked = !user2.IsLocked;
await userManager.UpdateAsync(user2);
IUnitOfWorkManager unitOfWorkManager = _provider.GetService<IUnitOfWorkManager>();
IUnitOfWork unitOfWork = _provider.GetUnitOfWork(true);
#if NET5_0
await unitOfWorkManager.CommitAsync();
await unitOfWork.CommitAsync();
#else
unitOfWorkManager.Commit();
unitOfWork.Commit();
#endif
user2 = await userManager.FindByIdAsync("2");
list.Add($"user2.IsLocked: {user2.IsLocked}");
Expand Down
Loading

0 comments on commit 78ea8fd

Please sign in to comment.