Exemple #1
0
        void Apply(DeletedRatingEvent @event)
        {
            var rating = Ratings.First(c => c.Id.Equals(@event.RatingId));

            if (rating != null)
            {
                rating.LastModifDate = @event.Date;
                rating.RecordState   = Constants.RECORD_STATE_DELETED;
            }
            //TODO: raise domain exception, if comment is null
        }
Exemple #2
0
        public void Handle(DeletedRatingEvent @event)
        {
            using (var db = new DisciturContext())
            {
                // get read-model Ids (ID-maps)
                int          lessonId  = _identityMapper.GetModelId <Lesson>(@event.Id);
                int          ratingtId = _identityMapper.GetModelId <LessonRating>(@event.RatingId);
                Lesson       lesson    = db.Lessons.Find(lessonId);
                LessonRating rating    = db.LessonRatings.Find(ratingtId);

                rating.LastModifDate = @event.Date;
                rating.RecordState   = Constants.RECORD_STATE_DELETED;
                rating.Vers++;
                // Persist changes
                db.Entry(rating).State = EntityState.Modified;

                lesson.Rate = CalculateAverageRating(rating);
                // TODO: is it correct to update readModel "devops fields" of lesson in this case?
                UpdateLessonArchFields(lesson, rating.LastModifUser, @event.Date, @event.Version);
                // Persist changes
                db.Entry(lesson).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Exemple #3
0
 void Apply(DeletedRatingEvent @event)
 {
     var rating = Ratings.First(c => c.Id.Equals(@event.RatingId));
     if (rating != null)
     {
         rating.LastModifDate = @event.Date;
         rating.RecordState = Constants.RECORD_STATE_DELETED;
     }
     //TODO: raise domain exception, if comment is null
 }