Пример #1
0
 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);
 }
Пример #2
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));
        }
Пример #3
0
        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;
        }
Пример #4
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);
 }
Пример #5
0
 private void Apply(UserRegistered @event)
 {
     Id = new UserId(@event.UserId);
     _name = new Name(@event.Name);
     _email = new EmailAddress(@event.Email);
 }
Пример #6
0
 public Participant(EmailAddress email)
 {
     Email = email;
 }