public DomainErrorList UpdatePrimaryEmail(string email) { // Validate var errors = new DomainErrorList(); if (email.IsNullOrWhiteSpace()) { errors.Add("Email address cannot be empty."); } if (errors) { return(errors); } // Execute _primaryEmail = email.Trim(); // Notify _domainEventsQueue.Add( new PersonPrimaryEmailUpdatedDomainEvent( Guid.NewGuid(), Id, Name, _primaryEmail)); return(errors); }
// Behaviors public DomainErrorList UpdateName(string firstName, string lastName) { // Validate var errors = new DomainErrorList(); if (firstName.IsNullOrWhiteSpace()) { errors.Add("FirstName cannot be empty."); } if (lastName.IsNullOrWhiteSpace()) { errors.Add("LastName cannot be empty"); } if (errors) { return(errors); } // Execute _firstName = firstName.Trim(); _lastName = lastName.Trim(); // Notify _domainEventsQueue.Add( new PersonNameUpdatedDomainEvent( Guid.NewGuid(), Id, Name, FirstName, LastName)); return(errors); }