public Task UserProfileChanged(UserProfileChangedIntegrationEvent @event) { _logger.LogInformation(@event.UserId.ToString()); _logger.LogInformation(@event.Name); _logger.LogInformation(@event.Avatar); return(Task.CompletedTask); }
public IActionResult Cap() { var @event = new UserProfileChangedIntegrationEvent() { UserId = 1, Name = "Test", Company = "Test" }; _capBus.Publish("UserProfileChanged", @event); return(Ok()); }
public static async Task PublishUserProfileChangedIntegrationEventAsync(this IServiceBusPublisher publisher, UserId userId, UserProfile profile) { var integrationEvent = new UserProfileChangedIntegrationEvent { UserId = userId, Profile = new ProfileDto { FirstName = profile.FirstName, LastName = profile.LastName, Gender = profile.Gender.ToEnum <EnumGender>() } }; await publisher.PublishAsync(integrationEvent); }
public async Task <bool> UpdateContactInfo(UserProfileChangedIntegrationEvent user, CancellationToken cancellationToken) { var contactbook = (await _contactContext.ContactBooks.FindAsync(q => q.UserId == user.UserId, null, cancellationToken)).FirstOrDefault(cancellationToken); if (contactbook == null) { return(true); } var contactids = contactbook.Contacts.Select(c => c.UserId); var filter = Builders <ContactBook> .Filter.And( Builders <ContactBook> .Filter.In(c => c.UserId, contactids), Builders <ContactBook> .Filter.ElemMatch(c => c.Contacts, contact => contact.UserId == user.UserId) ); var update = Builders <ContactBook> .Update .Set("Contacts.$.Name", user.Name) .Set("Contacts.$.Avatar", user.Avatar) .Set("Contacts.$.Company", user.Company) .Set("Contacts.$.Title", user.Title); var updateRes = _contactContext.ContactBooks.UpdateMany(filter, update); return(updateRes.MatchedCount == updateRes.ModifiedCount); }