Пример #1
0
        public Task Handle(BookFileSavedEvent request, CancellationToken cancellationToken)
        {
            var eventData = new BookDoneEvent(request.Id, request.Book);

            using (var transaction = new TransactionScope())
            {
                bookReadRepository.UpdateStatus(request.Id, eventData.Status);
                bookSagaEventRepository.Add(ConvertEvent(eventData));
                transaction.Complete();
            }

            return(Task.CompletedTask);
        }
Пример #2
0
        public async Task Handle(BookReadSavedEvent request, CancellationToken cancellationToken)
        {
            BookFileSavedEvent eventData;

            using (var transaction = new TransactionScope())
            {
                var savedBook = bookFileStorage.Save(request.Book);
                eventData = new BookFileSavedEvent(request.Id, savedBook);
                bookSagaEventRepository.Add(ConvertEvent(eventData));
                transaction.Complete();
            }
            await mediator.Publish(eventData);
        }