Added BlogUserSynchronizer

pull/782/head
Halil ibrahim Kalkan 6 years ago
parent 8fc0b124e0
commit 856907053a

@ -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…
Cancel
Save