Beispiel #1
0
        void Apply(EditedCommentEvent @event)
        {
            var comment = Comments.First(c => c.Id.Equals(@event.CommentId));

            if (comment != null)
            {
                comment.Content       = @event.Content;
                comment.LastModifDate = @event.Date;
            }
            //TODO: raise domain exception, if comment is null
        }
Beispiel #2
0
        public void Handle(EditedCommentEvent @event)
        {
            using (var db = new DisciturContext())
            {
                // get read-model Ids (ID-maps)
                int           lessonId  = _identityMapper.GetModelId <Lesson>(@event.Id);
                int           commentId = _identityMapper.GetModelId <LessonComment>(@event.CommentId);
                Lesson        lesson    = db.Lessons.Find(lessonId);
                LessonComment comment   = db.LessonComments.Find(commentId);

                comment.Content       = @event.Content;
                comment.Date          = @event.Date;
                comment.LastModifDate = @event.Date;
                comment.Vers++;
                // Persist changes
                db.Entry(comment).State = EntityState.Modified;

                // TODO: is it correct to update readModel "devops fields" of lesson in this case?
                UpdateLessonArchFields(lesson, comment.LastModifUser, @event.Date, @event.Version);
                // Persist changes
                db.Entry(lesson).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Beispiel #3
0
 void Apply(EditedCommentEvent @event)
 {
     var comment = Comments.First(c => c.Id.Equals(@event.CommentId));
     if (comment != null)
     {
         comment.Content = @event.Content;
         comment.LastModifDate = @event.Date;
     }
     //TODO: raise domain exception, if comment is null
 }