public async Task ExecuteAsync(DeletePageDirectoryCommand command, IExecutionContext executionContext) { var pageDirectory = await _dbContext .PageDirectories .Include(d => d.ChildPageDirectories) .SingleOrDefaultAsync(d => d.PageDirectoryId == command.PageDirectoryId); if (pageDirectory != null) { if (!pageDirectory.ParentPageDirectoryId.HasValue) { throw new ValidationException("Cannot delete the root page directory."); } pageDirectory.IsActive = false; using (var scope = _transactionScopeFactory.Create(_dbContext)) { await _commandExecutor.ExecuteAsync(new DeleteUnstructuredDataDependenciesCommand(PageDirectoryEntityDefinition.DefinitionCode, pageDirectory.PageDirectoryId), executionContext); await _dbContext.SaveChangesAsync(); scope.QueueCompletionTask(() => _cache.Clear()); await scope.CompleteAsync(); } } }
private async Task OnTransactionComplete(IReadOnlyCollection <PageDirectoryUrlChangedMessage> directoryMessages, IReadOnlyCollection <PageUrlChangedMessage> pageMessages) { _cache.Clear(); await _messageAggregator.PublishBatchAsync(directoryMessages); await _messageAggregator.PublishBatchAsync(pageMessages); }
private async Task OnTransactionComplete(int pageDirectoryId) { _cache.Clear(); await _messageAggregator.PublishAsync(new PageDirectoryAddedMessage() { PageDirectoryId = pageDirectoryId }); }
private Task OnTransactionComplete(UpdatePageDirectoryAccessRuleSetCommand command) { _pageDirectoryCache.Clear(); return(_messageAggregator.PublishAsync(new PageDirectoryAccessRulesUpdatedMessage() { PageDirectoryId = command.PageDirectoryId })); }
public async Task ExecuteAsync(UpdatePageDirectoryCommand command, IExecutionContext executionContext) { var pageDirectory = await _dbContext .PageDirectories .SingleOrDefaultAsync(w => w.PageDirectoryId == command.PageDirectoryId); EntityNotFoundException.ThrowIfNull(pageDirectory, command.PageDirectoryId); // Custom Validation await ValidateIsUniqueAsync(command, executionContext); await ValidateUrlPropertiesAllowedToChange(command, pageDirectory); pageDirectory.Name = command.Name; pageDirectory.UrlPath = command.UrlPath; pageDirectory.ParentPageDirectoryId = command.ParentPageDirectoryId; await _dbContext.SaveChangesAsync(); _cache.Clear(); }
public async Task ExecuteAsync(AddPageDirectoryCommand command, IExecutionContext executionContext) { // Custom Validation await ValidateIsUniqueAsync(command, executionContext); var pageDirectory = new PageDirectory(); pageDirectory.Name = command.Name; pageDirectory.UrlPath = command.UrlPath; pageDirectory.IsActive = true; pageDirectory.ParentPageDirectoryId = command.ParentPageDirectoryId; _entityAuditHelper.SetCreated(pageDirectory, executionContext); _dbContext.PageDirectories.Add(pageDirectory); await _dbContext.SaveChangesAsync(); _cache.Clear(); command.OutputPageDirectoryId = pageDirectory.PageDirectoryId; }