Exemplo n.º 1
0
        public User(Name name, EmailAddress email)
            : base(new UserId(email))
        {
            if (name == null) throw new ArgumentNullException("name");
            if (email == null) throw new ArgumentNullException("email");

            ApplyChange(new UserRegistered(Id, name, email));
        }
Exemplo n.º 2
0
 public void Handle(RegisterUser registerUser)
 {
     var user = _repository.GetById(registerUser.Email);
     if (user != null)
     {
         throw new EmailAlreadyRegisteredException(registerUser.Email);
     }
     var name = new Name(registerUser.Name);
     var emailAddress = new EmailAddress(registerUser.Email);
     user = new User(name, emailAddress);
     _repository.Save(user);
 }
Exemplo n.º 3
0
 private void Apply(UserRegistered @event)
 {
     Id = new UserId(@event.UserId);
     _name = new Name(@event.Name);
     _email = new EmailAddress(@event.Email);
 }