Пример #1
0
 public async Task Save(AttendantsReadModel readModel)
 {
     await _collection.ReplaceOneAsync(doc => doc.MeetupId == readModel.MeetupId, new AttendantsMongoDocument
     {
         MeetupId       = readModel.MeetupId,
         MeetupCapacity = readModel.MeetupCapacity,
         Waiting        = readModel.Waiting,
         NotGoing       = readModel.NotGoing,
         Going          = readModel.Going
     }, new UpdateOptions
     {
         IsUpsert = true
     });
 }
        public static void GivenPublishedMeetup(Action <AttendantsProjection, AttendantsReadModel> when, Action <AttendantsReadModel> then)
        {
            var projection = new AttendantsProjection();
            var readModel  = new AttendantsReadModel();

            projection.Project(
                readModel,
                new Events.MeetupCreated {
                Title = "EventSourcing a tope"
            },
                new Events.NumberOfSeatsUpdated {
                NumberOfSeats = 2
            },
                new Events.MeetupPublished {
            });

            when(projection, readModel);
            then(readModel);
        }
 public static AttendantsProjection RSVPDeclined(this AttendantsProjection projection, AttendantsReadModel readModel, Guid memberId)
 {
     projection.Project(readModel, new Events.RSVPDeclined {
         MemberId = memberId, DeclinedAt = DateTime.UtcNow
     });
     return(projection);
 }