public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyDeletedEvent> domainEvent) { context.MarkForDeletion(); }
public void Apply(IReadModelContext context, IDomainEvent <CompetitionAggregate, CompetitionId, CompetitionDeletedEvent> domainEvent) { context.MarkForDeletion(); }
public void Apply(IReadModelContext context, IDomainEvent<TestAggregate, TestId, PingEvent> e) { PingsReceived++; }
public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyDomainErrorAfterFirstEvent> domainEvent) { Id = domainEvent.AggregateIdentity.Value; DomainErrorAfterFirstReceived = true; }
public void Apply(IReadModelContext context, IDomainEvent <SchoolAggregate, SchoolId, InitialAgreementAchieved> domainEvent) { _status = GetSchools.SchoolStatus.HasAgreedInitially; }
public void Apply(IReadModelContext context, IDomainEvent <SchoolAggregate, SchoolId, FixedTermAgreementSigned> domainEvent) { _status = GetSchools.SchoolStatus.HasSignedAgreement; _agreementEndDate = domainEvent.AggregateEvent.AgreementEndDate; }
public void Apply(IReadModelContext context, IDomainEvent <TestAggregate, TestId, PingEvent> e) { PingEventsReceived = true; }
protected abstract Task <ReadModelUpdateResult <TReadModel> > UpdateAsync( IReadModelContext readModelContext, IReadOnlyCollection <IDomainEvent> domainEvents, ReadModelEnvelope <TReadModel> readModelEnvelope, CancellationToken cancellationToken);
public void Apply(IReadModelContext context, IDomainEvent <Product, ProductId, MagicNumberIcremented> domainEvent) { _id = domainEvent.AggregateIdentity.Value; MagicNumber += domainEvent.AggregateEvent.MagicNumber; }
public void Apply(IReadModelContext context, IDomainEvent <AggregateB, IdB, EventB> domainEvent) { _indexes.Add(domainEvent.AggregateEvent.Index); }
public override async Task UpdateAsync(IReadOnlyCollection <ReadModelUpdate> readModelUpdates, IReadModelContext readModelContext, Func <IReadModelContext, IReadOnlyCollection <IDomainEvent>, ReadModelEnvelope <TReadModel>, CancellationToken, Task <ReadModelEnvelope <TReadModel> > > updateReadModel, CancellationToken cancellationToken) { foreach (var update in readModelUpdates) { var envelope = await GetAsync(update.ReadModelId, cancellationToken).ConfigureAwait(false); var updatedModel = await updateReadModel(readModelContext, update.DomainEvents, envelope, cancellationToken).ConfigureAwait(false); await _dynamoDBContext.SaveAsync(updatedModel.ReadModel, cancellationToken).ConfigureAwait(false); } }
public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyPingEvent> domainEvent) { Id = domainEvent.AggregateEvent.PingId; }
public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyMessageAddedEvent> domainEvent) { ThingyId = domainEvent.AggregateIdentity.Value; Message = domainEvent.AggregateEvent.ThingyMessage.Message; }
public void Apply(IReadModelContext context, IDomainEvent <CargoAggregate, CargoId, CargoBookedEvent> domainEvent) { Id = domainEvent.AggregateIdentity; Route = domainEvent.AggregateEvent.Route; }
public void Apply(IReadModelContext context, IDomainEvent <TestAggregate, TestId, DomainErrorAfterFirstEvent> e) { DomainErrorAfterFirstEventsReceived = true; }
public abstract Task UpdateAsync( IReadOnlyCollection <ReadModelUpdate> readModelUpdates, IReadModelContext readModelContext, Func <IReadModelContext, IReadOnlyCollection <IDomainEvent>, ReadModelEnvelope <TReadModel>, CancellationToken, Task <ReadModelEnvelope <TReadModel> > > updateReadModel, CancellationToken cancellationToken);
public void Apply(IReadModelContext context, IDomainEvent <OrderAggregate, OrderId, OrderCreated> domainEvent) { this.Id = domainEvent.AggregateIdentity.Value; this.Username = domainEvent.AggregateEvent.User.Value; }
public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyPingEvent> domainEvent) { PingsReceived++; }
public async Task UpdateAsync( IReadOnlyCollection <ReadModelUpdate> readModelUpdates, IReadModelContext readModelContext, Func <IReadModelContext, IReadOnlyCollection <IDomainEvent>, ReadModelEnvelope <TReadModel>, CancellationToken, Task <ReadModelEnvelope <TReadModel> > > updateReadModel, CancellationToken cancellationToken) { var readModelDescription = _readModelDescriptionProvider.GetReadModelDescription <TReadModel>(); _log.Verbose(() => { var readModelIds = readModelUpdates .Select(u => u.ReadModelId) .Distinct() .OrderBy(i => i) .ToList(); return($"Updating read models of type '{typeof(TReadModel).PrettyPrint()}' with IDs '{string.Join(", ", readModelIds)}' in node '{readModelDescription.RootNodeName}'"); }); foreach (var readModelUpdate in readModelUpdates) { try { TReadModel firebaseResult = null; if (_firebaseReadStoreConfiguration.UseBackupStore) { firebaseResult = await _readModelBackUpStore.GetAsync <TReadModel>(readModelDescription.RootNodeName.Value, readModelUpdate.ReadModelId, cancellationToken); } else { var response = await _firebaseClient.GetAsync($"{readModelDescription.RootNodeName}/{readModelUpdate.ReadModelId}"); var dynamicResult = response.ResultAs <dynamic>(); if (dynamicResult != null) { Dictionary <string, bool> children = new Dictionary <string, bool>(); foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(dynamicResult)) { children.Add(prop.Name, true); } firebaseResult = new TReadModel(); firebaseResult.Children = children; } } var readModelEnvelope = (firebaseResult != null) ? ReadModelEnvelope <TReadModel> .With(readModelUpdate.ReadModelId, firebaseResult) : ReadModelEnvelope <TReadModel> .Empty(readModelUpdate.ReadModelId); readModelEnvelope = await updateReadModel( readModelContext, readModelUpdate.DomainEvents, readModelEnvelope, cancellationToken).ConfigureAwait(false); if (_firebaseReadStoreConfiguration.UseBackupStore) { if (readModelEnvelope.ReadModel.Children != null && readModelEnvelope.ReadModel.Children.Count > 0) { await _readModelBackUpStore.UpdateAsync(readModelDescription.RootNodeName.Value, readModelUpdate.ReadModelId, readModelEnvelope.ReadModel, cancellationToken); await _readModelBackUpStore.TryFirebaseCoupleOfTimesAsync <TReadModel, SetResponse, Dictionary <string, bool> >(_firebaseClient.SetAsync, readModelDescription.RootNodeName.Value, readModelUpdate.ReadModelId, readModelEnvelope.ReadModel.Children); } else { await _readModelBackUpStore.DeleteOneAsync <TReadModel>(readModelDescription.RootNodeName.Value, readModelUpdate.ReadModelId, cancellationToken); await _readModelBackUpStore.TryFirebaseCoupleOfTimesAsync <TReadModel, FirebaseResponse>(_firebaseClient.DeleteAsync, readModelDescription.RootNodeName.Value, readModelUpdate.ReadModelId); } } else { if (readModelEnvelope.ReadModel.Children != null && readModelEnvelope.ReadModel.Children.Count > 0) { await _firebaseClient.SetAsync($"{readModelDescription.RootNodeName}/{readModelUpdate.ReadModelId}", readModelEnvelope.ReadModel.Children); } else { await _firebaseClient.DeleteAsync($"{readModelDescription.RootNodeName}/{readModelUpdate.ReadModelId}"); } } } catch (Exception) { throw; } } }
public void Apply(IReadModelContext context, IDomainEvent <SchoolAggregate, SchoolId, PermanentAgreementSigned> domainEvent) { _status = GetSchools.SchoolStatus.HasSignedAgreement; _agreementEndDate = null; }
public void Apply(IReadModelContext context, IDomainEvent <InventoryItemAggregate, InventoryItemId, InventoryItemRenamedEvent> domainEvent) { Name = domainEvent.AggregateEvent.NewName; }
public void Apply(IReadModelContext context, IDomainEvent <SchoolAggregate, SchoolId, SchoolResignedFromCooperation> domainEvent) { _status = GetSchools.SchoolStatus.HasResigned; _resignationEndDate = domainEvent.AggregateEvent.PotentialNextContactDate; }
public void Apply(IReadModelContext context, IDomainEvent <InventoryItemAggregate, InventoryItemId, InventoryItemDeactivatedEvent> domainEvent) { context.MarkForDeletion(); }
public void Apply(IReadModelContext context, IDomainEvent<TestAggregate, TestId, DomainErrorAfterFirstEvent> e) { DomainErrorAfterFirstReceived = true; }
public void Apply(IReadModelContext context, IDomainEvent <InventoryItemAggregate, InventoryItemId, InventoryItemCreatedEvent> domainEvent) { Id = domainEvent.AggregateIdentity.ToString(); Name = domainEvent.AggregateEvent.Name; }
public void Apply(IReadModelContext context, IDomainEvent <ThingyAggregate, ThingyId, ThingyPingEvent> domainEvent) { Id = domainEvent.AggregateIdentity.Value; PingsReceived++; }
public async Task UpdateAsync(IReadOnlyCollection <ReadModelUpdate> readModelUpdates, IReadModelContext readModelContext, Func <IReadModelContext, IReadOnlyCollection <IDomainEvent>, ReadModelEnvelope <TReadModel>, CancellationToken, Task <ReadModelEnvelope <TReadModel> > > updateReadModel, CancellationToken cancellationToken) { var readModelDescription = _readModelDescriptionProvider.GetReadModelDescription <TReadModel>(); _log.Verbose(() => { var readModelIds = readModelUpdates .Select(u => u.ReadModelId) .Distinct() .OrderBy(i => i) .ToList(); return($"Updating read models of type '{typeof(TReadModel).PrettyPrint()}' with _ids '{string.Join(", ", readModelIds)}' in collection '{readModelDescription.RootCollectionName}'"); }); foreach (var readModelUpdate in readModelUpdates) { var collection = _mongoDatabase.GetCollection <TReadModel>(readModelDescription.RootCollectionName.Value); var readModelEnvelope = ReadModelEnvelope <TReadModel> .Empty(readModelUpdate.ReadModelId); readModelEnvelope = await updateReadModel(readModelContext, readModelUpdate.DomainEvents, readModelEnvelope, cancellationToken).ConfigureAwait(false); readModelEnvelope.ReadModel._id = ObjectIdGenerator.Instance.GenerateId(collection, readModelEnvelope.ReadModel); await collection.InsertOneAsync( readModelEnvelope.ReadModel, new InsertOneOptions { BypassDocumentValidation = true }, cancellationToken); } }
public void Apply(IReadModelContext context, IDomainEvent <CompetitionAggregate, CompetitionId, EntryTimeCorrectedEvent> domainEvent) { TimeInMillis = domainEvent.AggregateEvent.TimeInMillis; }
public void Apply(IReadModelContext context, IDomainEvent <Domain.Booking.Booking, BookingId, PassengerAddedEvent> domainEvent) { Passengers.Add(domainEvent.AggregateEvent.Passenger.ToReadModel()); }
public void Apply( IReadModelContext context, IDomainEvent <ExampleAggregate, ExampleId, ExampleEvent> domainEvent) { MagicNumber.Add(domainEvent.AggregateEvent.MagicNumber); }
public void Apply(IReadModelContext context, IDomainEvent <TreatmentMachineAggregate, TreatmentMachineId, TreatmentMachineWithAdvancedCapabilityIsAddedEvent> domainEvent) { Id = domainEvent.AggregateEvent.Id.Value; Name = domainEvent.AggregateEvent.Name; HasAdvancedCapability = true; }
public void Apply(IReadModelContext context, IDomainEvent <Aggregate, AggregateIdentity, Event> domainEvent) { Formula = domainEvent.AggregateEvent.Formula; }
public ReadModelProductDao(IReadModelContext context) { if (context == null) throw new ArgumentNullException(nameof(context)); _context = context; }