public override Task Execute(BehaviorContext <UpdateDocumentState, DocumentUpdatedInStorageEvent> context, Behavior <UpdateDocumentState, DocumentUpdatedInStorageEvent> next)
        {
            var doc = context.Data.PayLoad.ToDocument();

            _documentRepository.UpdateAsync(doc).Wait();
            _documentUnitOfWork.CommitAsync().Wait();
            return(next.Execute(context));
        }
Example #2
0
        public override Task Execute(BehaviorContext <DeleteDocumentState, DocumentDeletedFromStorageEvent> context, Behavior <DeleteDocumentState, DocumentDeletedFromStorageEvent> next)
        {
            var doc = context.Data.PayLoad.ToEmptyDocumentWithId();

            _documentRepository.DeleteAsync(doc).Wait();
            _documentUnitOfWork.CommitAsync().Wait();
            return(next.Execute(context));
        }
        protected override async Task <Result> HandleEx(UpdateDocumentPropertiesCommand command, CancellationToken cancellationToken = default)
        {
            await _documentRepository.UpdateAsync(new DocumentFactory(Bus.User.Id, _clock.Now).CreateFromCommand(command))
            .ConfigureAwait(false);

            await _documentUnitOfWork.CommitAsync().ConfigureAwait(false);

            return(Result.Success());
        }