예제 #1
0
 private void Apply(DiscussionOpened discussion)
 {
     Id = new DiscussionId(discussion.DiscussionId);
     _topic = new Topic(discussion.Topic);
     _participants = discussion.EmailsOfParticipants.Select(x => new Participant(new EmailAddress(x))).ToList();
     _linkId = new LinkId(discussion.LinkId);
     _posts = new List<Post>();
 }
예제 #2
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);
 }
예제 #3
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));
        }
예제 #4
0
        public void Handle(ShareLink cmd)
        {
            var linkId = new LinkId(cmd.Link);
            var link = _repository.GetById(linkId);

            if (link == null)
            {
                var url = new Uri(cmd.Link);
                link = new Link(url);
            }
            var topic = new Topic(cmd.Topic);
            var emailsOfReceivers = cmd.EmailsOfReceivers.Select(x => new Receiver(new EmailAddress(x))).ToArray();
            var receivers = new ListOfReceivers(emailsOfReceivers);
            var sharer = new Sharer(new EmailAddress(cmd.EmailOfSharer));
            link.Share(topic, sharer, receivers);
            _repository.Save(link);
        }
예제 #5
0
파일: Link.cs 프로젝트: SabrinaMH/ShareIt
 public void Apply(LinkRegistered @event)
 {
     Id = new LinkId(@event.LinkId);
     _urlOfLink = new Uri(@event.Url);
 }