public async Task HandleAsync(CreateAddress command, ICorrelationContext context) { Customer customer = await _customerRepo.GetAsync(command.UserId); if (customer is null) { throw new MedParkException("customer_does_not_create", $"Customer {command.UserId} does not exist."); } Address addr = new Address(command.Id); addr.SetCustomer(command.UserId); addr.SetAddressType(command.AddressType); addr.SetAddress(command.AddressLine1, command.AddressLine2, command.AddressLine3, command.PostalCode); addr.Use(); //save address await _addressRepo.AddAsync(addr); //Publish address created event AddressCreated addrCreated = new AddressCreated(command.Id, command.AddressLine1, command.AddressLine2, command.AddressLine3, command.PostalCode, command.AddressType, customer.Id); await _busPublisher.PublishAsync <AddressCreated>(addrCreated, null); }
public void OnAddressCreated(AddressCreated e) { City = e.City; Street = e.Street; ZipCode = e.ZipCode; Number = e.Number; Function = e.Function; Id = e.Id; }
protected virtual void OnAddressCreated() { CreateNotification(EventActionType.Created); AddressCreated?.Invoke(this, new NewNotificationEventArgs(this)); }
private Address(AggregateRoot root, AddressCreated e) : this(root, e.Id) { Apply(e); }