void IOrginator.SetMemento(IMemento memento) { var clientMemento = (ClientMemento) memento; Id = clientMemento.Id; Version = clientMemento.Version; _clientName = new ClientName(clientMemento.ClientName); _address = new Address(clientMemento.Street, clientMemento.StreetNumber, clientMemento.PostalCode, clientMemento.City); _phoneNumber = new PhoneNumber(clientMemento.PhoneNumber); _accounts.AddRange(clientMemento.Accounts); clientMemento.BankCardMementos.ForEach(x => { var bankCard = new BankCard(); ((IOrginator)bankCard).SetMemento(x); _bankCards.Add(bankCard); }); }
public static Client CreateNew(ClientName clientName, Address address, PhoneNumber phoneNumber) { return new Client(clientName, address, phoneNumber); }
private Client(ClientName clientName, Address address, PhoneNumber phoneNumber) : this() { Apply(new ClientCreatedEvent(Guid.NewGuid(), clientName.Name, address.Street, address.StreetNumber, address.PostalCode, address.City, phoneNumber.Number)); }
private void onNewClientCreated(ClientCreatedEvent clientCreatedEvent) { Id = clientCreatedEvent.ClientId; _clientName = new ClientName(clientCreatedEvent.ClientName); _address = new Address(clientCreatedEvent.Street, clientCreatedEvent.StreetNumber, clientCreatedEvent.PostalCode, clientCreatedEvent.City); _phoneNumber = new PhoneNumber(clientCreatedEvent.PhoneNumber); }
private void onClientPhoneNumberWasChanged(ClientPhoneNumberChangedEvent clientPhoneNumberChangedEvent) { _phoneNumber = new PhoneNumber(clientPhoneNumberChangedEvent.PhoneNumber); }
public void UpdatePhoneNumber(PhoneNumber phoneNumber) { IsClientCreated(); Apply(new ClientPhoneNumberChangedEvent(phoneNumber.Number)); }