Пример #1
0
 public void Handle(OpenDiscussion openDiscussion)
 {
     var participants = openDiscussion.IdsOfParticipants.Select(x => new Participant(new EmailAddress(x))).ToList();
     var linkId = new LinkId(openDiscussion.LinkId);
     var topic = new Topic(openDiscussion.Topic);
     var initiator = new Participant(new EmailAddress(openDiscussion.IdOfInitiator));
     var discussion = new Discussion(linkId, topic, initiator, participants);
     _repository.Save(discussion);
 }
Пример #2
0
        public Discussion(LinkId linkId, Topic topic, Participant initiator, List<Participant> participants)
            : base(new DiscussionId())
        {
            if (linkId == null) throw new ArgumentNullException("linkId");
            if (topic == null) throw new ArgumentNullException("topic");
            if (initiator == null) throw new ArgumentNullException("initiator");
            if (participants == null || !participants.Any()) throw new ArgumentException(String.Format("{0} cannot be null or empty", participants));

            var emailsOfParticipants = participants.Select(x => x.Email.Value).ToList();
            ApplyChange(new DiscussionOpened(new Guid(Id), linkId, topic, initiator.Email.Value, emailsOfParticipants));
        }