public Person Take(EmailAddressCreateCommand command) { var mail = new EmailAddress(command); this.EmailAddresses.Add(mail); base.AddEvent(new PersonUpdatedDomainEvent { AggregateRootId = Id, CommandJson = JsonConvert.SerializeObject(command), UserId = command.UserId }); return(this); }
public async Task <ICommandHandlerAggregateAnswer> HandleAsync(EmailAddressCreateCommand command) { var answer = new CommandHandlerAggregateAnswer(); var person = await personRepository.Query(command.PersonId); if (person.IsNotNull()) { answer.ValidationResult = this.createMailValidationHandler.Validate(command); if (command.IsValid) { answer.AggregateRoot = await personRepository.Update(person.Take(command)); } } return(answer); }
public EmailAddress(EmailAddressCreateCommand command) { this.CopyPropertiesFrom(command); }