Пример #1
0
        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());
        }
Пример #2
0
        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());
        }