示例#1
0
        protected override async Task <ReadModelEnvelope <TReadModel> > UpdateAsync(
            IReadModelContext readModelContext,
            IReadOnlyCollection <IDomainEvent> domainEvents,
            ReadModelEnvelope <TReadModel> readModelEnvelope,
            CancellationToken cancellationToken)
        {
            var readModel = readModelEnvelope.ReadModel ?? new TReadModel();
            await ReadModelDomainEventApplier.UpdateReadModelAsync(readModel, domainEvents, readModelContext, cancellationToken).ConfigureAwait(false);

            return(ReadModelEnvelope <TReadModel> .With(readModel));
        }
示例#2
0
        protected override async Task <ReadModelEnvelope <TReadModel> > UpdateAsync(
            IReadModelContext readModelContext,
            IReadOnlyCollection <IDomainEvent> domainEvents,
            ReadModelEnvelope <TReadModel> readModelEnvelope,
            CancellationToken cancellationToken)
        {
            var readModel = readModelEnvelope.ReadModel ?? await ReadModelFactory.CreateAsync(readModelEnvelope.ReadModelId, cancellationToken).ConfigureAwait(false);

            await ReadModelDomainEventApplier.UpdateReadModelAsync(readModel, domainEvents, readModelContext, cancellationToken).ConfigureAwait(false);

            var readModelVersion = domainEvents.Max(e => e.AggregateSequenceNumber);

            return(ReadModelEnvelope <TReadModel> .With(readModelEnvelope.ReadModelId, readModel, readModelVersion));
        }
        protected override async Task <ReadModelEnvelope <TReadModel> > UpdateAsync(
            IReadModelContext readModelContext,
            IReadOnlyCollection <IDomainEvent> domainEvents,
            ReadModelEnvelope <TReadModel> readModelEnvelope,
            CancellationToken cancellationToken)
        {
            var readModel = readModelEnvelope.ReadModel ?? await ReadModelFactory.CreateAsync(readModelEnvelope.ReadModelId, cancellationToken).ConfigureAwait(false);

            await ReadModelDomainEventApplier.UpdateReadModelAsync(
                readModel,
                domainEvents,
                readModelContext,
                cancellationToken)
            .ConfigureAwait(false);

            return(ReadModelEnvelope <TReadModel> .With(
                       readModelEnvelope.ReadModelId,
                       readModel,
                       readModelEnvelope.Version.GetValueOrDefault() + 1 // the best we can do
                       ));
        }