public void Handle(SubmitPost submitPost) { var emailOfPoster = new EmailAddress(submitPost.EmailOfPoster); var discussionId = new DiscussionId(submitPost.DiscussionId); var discussion = _repository.GetById(discussionId); discussion.SubmitPost(emailOfPoster, submitPost.BodyText); _repository.Save(discussion); }
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)); }
public Post(EmailAddress emailOfPoster, string bodyText, int postNumber) { if (String.IsNullOrWhiteSpace(bodyText)) throw new ArgumentException(String.Format("{0} cannot be null or white spaces", bodyText)); if (emailOfPoster == null) throw new ArgumentNullException("emailOfPoster"); if (postNumber < 0) throw new ArgumentException(string.Format("{0} cannot be negative", postNumber)); EmailOfPoster = emailOfPoster; BodyText = bodyText; PostNumber = postNumber; }
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); }
private void Apply(UserRegistered @event) { Id = new UserId(@event.UserId); _name = new Name(@event.Name); _email = new EmailAddress(@event.Email); }
public Participant(EmailAddress email) { Email = email; }