添加项目文件。
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using ContactService.Domain;
|
||||
using ContactService.Infrastructure;
|
||||
using IM.Commons.IntegrationEvents;
|
||||
using MassTransit;
|
||||
|
||||
namespace ContactService.WebApi.Application.EventHandler
|
||||
{
|
||||
public class UserProfileUpdateHandler : IConsumer<UserProfileUpdateEvent>
|
||||
{
|
||||
private readonly ContactDbContext contactDb;
|
||||
private readonly IFriendReposity reposity;
|
||||
|
||||
public UserProfileUpdateHandler(ContactDbContext contactDb, IFriendReposity reposity)
|
||||
{
|
||||
this.contactDb = contactDb;
|
||||
this.reposity = reposity;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<UserProfileUpdateEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
var friends = await reposity.FindByTargetAsync(@event.UserId);
|
||||
|
||||
foreach (var friend in friends)
|
||||
{
|
||||
friend.UpdateUserInfo(
|
||||
new Domain.ValueObjects.UserProfile(
|
||||
@event.UserId, @event.Avatar, @event.NickName));
|
||||
}
|
||||
|
||||
await contactDb.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user