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

            if (comment != null)
            {
                comment.LastModifDate = @event.Date;
                comment.RecordState   = Constants.RECORD_STATE_DELETED;
            }
            //TODO: raise domain exception, if comment is null
        }
Exemple #2
0
        public void Handle(DeletedCommentEvent @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.LastModifDate = @event.Date;
                comment.RecordState   = Constants.RECORD_STATE_DELETED;
                // 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();
            }
        }
Exemple #3
0
 void Apply(DeletedCommentEvent @event)
 {
     var comment = Comments.First(c => c.Id.Equals(@event.CommentId));
     if (comment != null)
     {
         comment.LastModifDate = @event.Date;
         comment.RecordState = Constants.RECORD_STATE_DELETED;
     }
     //TODO: raise domain exception, if comment is null
 }