public async Task Create(Concept concept, CancellationToken cancellationToken = default(CancellationToken)) { var context = await _ddpContextProvider.Get(); var conceptTable = new ConceptTable { ConceptId = concept.ConceptId, Name = concept.Name, Description = concept.Description }; await context.ConceptTables.AddAsync(conceptTable, cancellationToken); await _eventStore.StoreEventsFor(concept, concept.ConceptId, cancellationToken); await _domainEventDispatcher.QueueEvents(concept.GetMutatingEvents()); }
public async Task Update(Concept concept, CancellationToken cancellationToken = default(CancellationToken)) { var context = await _ddpContextProvider.Get(); var existing = await context.FindAsync <ConceptTable>(concept.ConceptId); if (existing == null) { throw new Exception("nope doesn't exist"); } existing.Description = concept.Description; existing.Name = concept.Name; await context.SaveChangesAsync(cancellationToken); await _eventStore.StoreEventsFor(concept, concept.ConceptId, cancellationToken); await _domainEventDispatcher.QueueEvents(concept.GetMutatingEvents()); }