private void When(PostCreatedEvent e)
 {
     Id           = e.Id;
     Title        = e.Title;
     LastModified = e.Created;
     Question     = new Question
     {
         Id    = e.QuestionId,
         Body  = e.Body,
         Votes = 0,
         Post  = this
     };
 }
Beispiel #2
0
        public DomainEventStream GetAggregateRestoreEventStream(string postId, Post nullObject)
        {
            using (var connection = new SqlConnection(ConfigSettings.Forum_DBConnectionString))
            {
                dynamic          post             = connection.QueryList <dynamic>(new { Id = postId }, Constants.PostTable).SingleOrDefault();
                PostCreatedEvent postCreatedEvent = null;

                postCreatedEvent = new PostCreatedEvent(
                    (string)post.Id, (int)post.Version, (string)post.Subject, (string)post.Body, (string)post.SectionId, (string)post.AuthorId);
                postCreatedEvent.Version   = (int)post.Version;
                postCreatedEvent.Timestamp = (DateTime)post.CreatedOn;

                PostReplyStatisticInfo postReplyStatisticInfo = new PostReplyStatisticInfo(
                    (string)post.MostRecentReplyId, (string)post.MostRecentReplierId, (DateTime)post.LastUpdateTime, (int)post.ReplyCount);
                PostReplyStatisticInfoChangedEvent postReplyStatisticInfoChangedEvent = new PostReplyStatisticInfoChangedEvent(
                    (string)post.Id, (int)post.Version, postReplyStatisticInfo);
                postReplyStatisticInfoChangedEvent.Version   = (int)post.Version;
                postReplyStatisticInfoChangedEvent.Timestamp = (DateTime)post.LastUpdateTime;

                IDomainEvent[]    events      = new IDomainEvent[] { postCreatedEvent, postReplyStatisticInfoChangedEvent };
                DomainEventStream eventStream = new DomainEventStream(postId, postCreatedEvent.Version, events);
                return(eventStream);
            }
        }