async Task INotificationHandler <ProductUpdatedDomainEvent> .Handle(ProductUpdatedDomainEvent notification, CancellationToken cancellationToken) { try { await eventStateContext .AddNotification <ProductUpdatedDomainEvent> ( (productUpdatedDomainEvent) => ( productUpdatedDomainEvent.UpdateProductResponse.UpdateNewProductResponse.ProductName != productUpdatedDomainEvent.UpdateProductResponse.UpdateOldProductResponse.ProductNameOldValue ) , new ProductNameChangedIntegrationEvent() { ProductIdentity = notification?.UpdateProductResponse?.UpdateNewProductResponse?.ProductIdentity, ProductName = notification?.UpdateProductResponse?.UpdateNewProductResponse?.ProductName } ) .AddNotification <ProductUpdatedDomainEvent> ( (productUpdatedDomainEvent) => ( productUpdatedDomainEvent.UpdateProductResponse.UpdateNewProductResponse.UnitPrice != productUpdatedDomainEvent.UpdateProductResponse.UpdateOldProductResponse.UnitPriceOldValue ), new ProductUnitPriceChangedIntegrationEvent() { ProductIdentity = notification?.UpdateProductResponse.UpdateNewProductResponse.ProductIdentity, UnitPrice = notification?.UpdateProductResponse?.UpdateNewProductResponse?.UnitPrice } ) .PublishNotification(notification); } catch { throw; } }
async Task INotificationHandler <CustomerUpdatedDomainEvent> .Handle(CustomerUpdatedDomainEvent notification, CancellationToken cancellationToken) { try { //List<Task> tasks = new List<Task>(); //if (notification.UpdateCustomerResponse.UpdateNewCustomerResponse.FirstName != notification.UpdateCustomerResponse.UpdateOldCustomerResponse.FirstNameOldValue // || // notification.UpdateCustomerResponse.UpdateNewCustomerResponse.LastName != notification.UpdateCustomerResponse.UpdateOldCustomerResponse.LastNameOldValue // ) //{ // tasks.Add(mediator.Publish<CustomerNameChangedIntegrationEvent>(new CustomerNameChangedIntegrationEvent() // { // CustomerIdentity = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.CustomerIdentity, // FirstName = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.FirstName, // LastName = notification.UpdateCustomerResponse.UpdateNewCustomerResponse?.LastName // })); //} //if (notification.UpdateCustomerResponse.UpdateNewCustomerResponse.MobileNo != notification.UpdateCustomerResponse.UpdateOldCustomerResponse.MobileNoOldValue) //{ // tasks.Add(mediator.Publish<CustomerMobileNumberChangedIntegrationEvent>(new CustomerMobileNumberChangedIntegrationEvent() // { // CustomerIdentity = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.CustomerIdentity, // MobileNo = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.MobileNo // })); //} //await Task.WhenAll(tasks); await eventStateContext .AddNotification <CustomerUpdatedDomainEvent>( (customerUpdateDomainEvent) => ( customerUpdateDomainEvent.UpdateCustomerResponse.UpdateNewCustomerResponse.FirstName != customerUpdateDomainEvent.UpdateCustomerResponse.UpdateOldCustomerResponse.FirstNameOldValue || customerUpdateDomainEvent.UpdateCustomerResponse.UpdateNewCustomerResponse.LastName != customerUpdateDomainEvent.UpdateCustomerResponse.UpdateOldCustomerResponse.LastNameOldValue ), new CustomerNameChangedIntegrationEvent() { CustomerIdentity = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.CustomerIdentity, FirstName = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.FirstName, LastName = notification.UpdateCustomerResponse.UpdateNewCustomerResponse?.LastName } ) .AddNotification <CustomerUpdatedDomainEvent>( (customerUpdateDomainEvent) => ( customerUpdateDomainEvent.UpdateCustomerResponse.UpdateNewCustomerResponse.MobileNo != customerUpdateDomainEvent.UpdateCustomerResponse.UpdateOldCustomerResponse.MobileNoOldValue ), new CustomerMobileNumberChangedIntegrationEvent() { CustomerIdentity = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.CustomerIdentity, MobileNo = notification?.UpdateCustomerResponse?.UpdateNewCustomerResponse?.MobileNo } ) .PublishNotification(notification); } catch { throw; } }