Example #1
0
        public void Handle(EditedRatingEvent @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.Rating        = @event.Rating;
                rating.Content       = @event.Content;
                rating.LastModifDate = @event.Date;
                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();
            }
        }
Example #2
0
        void Apply(EditedRatingEvent @event)
        {
            var rating = Ratings.First(c => c.Id.Equals(@event.RatingId));

            if (rating != null)
            {
                rating.Content       = @event.Content;
                rating.LastModifDate = @event.Date;
            }
            //TODO: raise domain exception, if comment is null
        }
Example #3
0
 void Apply(EditedRatingEvent @event)
 {
     var rating = Ratings.First(c => c.Id.Equals(@event.RatingId));
     if (rating != null)
     {
         rating.Content = @event.Content;
         rating.LastModifDate = @event.Date;
     }
     //TODO: raise domain exception, if comment is null
 }