mirror of https://github.com/abpframework/abp.git
1 changed files with 39 additions and 0 deletions
@ -0,0 +1,39 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Blogging.Users |
|||
{ |
|||
public class BlogUserSynchronizer : |
|||
IDistributedEventHandler<EntityUpdatedEto<UserEto>>, |
|||
ITransientDependency |
|||
{ |
|||
protected IBlogUserRepository UserRepository { get; } |
|||
protected IBlogUserLookupService UserLookupService { get; } |
|||
|
|||
public BlogUserSynchronizer(IBlogUserRepository userRepository, IBlogUserLookupService userLookupService) |
|||
{ |
|||
UserRepository = userRepository; |
|||
UserLookupService = userLookupService; |
|||
} |
|||
|
|||
public async Task HandleEventAsync(EntityUpdatedEto<UserEto> eventData) |
|||
{ |
|||
var user = await UserRepository.FindAsync(eventData.Entity.Id); |
|||
if (user == null) |
|||
{ |
|||
//TODO: Why needed (ask to @ebicoglu)?
|
|||
user = await UserLookupService.FindByIdAsync(eventData.Entity.Id); |
|||
if (user == null) |
|||
{ |
|||
return; |
|||
} |
|||
} |
|||
|
|||
user.Update(eventData.Entity); |
|||
await UserRepository.UpdateAsync(user); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue