Esempio n. 1
0
        public async Task ExecuteAsync(AddPageCommand command, IExecutionContext executionContext)
        {
            // Custom Validation
            await ValidateIsPageUniqueAsync(command, executionContext);

            var page = await MapPage(command, executionContext);

            _dbContext.Pages.Add(page);

            using (var scope = _transactionScopeFactory.Create(_dbContext))
            {
                await _dbContext.SaveChangesAsync();

                await _pageStoredProcedures.UpdatePublishStatusQueryLookupAsync(page.PageId);

                scope.Complete();
            }

            _pageCache.ClearRoutes();

            // Set Ouput
            command.OutputPageId = page.PageId;

            await _messageAggregator.PublishAsync(new PageAddedMessage()
            {
                PageId = page.PageId,
                HasPublishedVersionChanged = command.Publish
            });
        }
        private Task OnTransactionComplete(AddPageCommand command, Page page)
        {
            _pageCache.ClearRoutes();

            return(_messageAggregator.PublishAsync(new PageAddedMessage()
            {
                PageId = page.PageId,
                HasPublishedVersionChanged = command.Publish
            }));
        }
        public async Task ExecuteAsync(AddPageCommand command, IExecutionContext executionContext)
        {
            // Custom Validation
            ValidateIsPageUnique(command, executionContext);

            var page = await MapPage(command, executionContext);

            _dbContext.Pages.Add(page);
            await _dbContext.SaveChangesAsync();

            _pageCache.ClearRoutes();

            // Set Ouput
            command.OutputPageId = page.PageId;

            await _messageAggregator.PublishAsync(new PageAddedMessage()
            {
                PageId = page.PageId,
                HasPublishedVersionChanged = command.Publish
            });
        }