Exemple #1
0
        public async Task ExecuteAsync(UpdatePageUrlCommand command, IExecutionContext executionContext)
        {
            var page = await _dbContext
                       .Pages
                       .FilterActive()
                       .FilterByPageId(command.PageId)
                       .Include(p => p.Locale)
                       .Include(p => p.PageDirectory)
                       .SingleOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(page, command.PageId);

            await ValidateIsPageUniqueAsync(command, page, executionContext);

            await MapPageAsync(command, executionContext, page);

            var isPublished = page.PublishStatusCode == PublishStatusCode.Published;

            await _dbContext.SaveChangesAsync();

            _pageCache.Clear(command.PageId);

            await _messageAggregator.PublishAsync(new PageUrlChangedMessage()
            {
                PageId = command.PageId,
                HasPublishedVersionChanged = isPublished
            });
        }
Exemple #2
0
        public async Task ExecuteAsync(DeletePageCommand command, IExecutionContext executionContext)
        {
            var page = await _dbContext
                       .Pages
                       .SingleOrDefaultAsync(p => p.PageId == command.PageId);

            if (page != null)
            {
                page.IsDeleted = true;
                using (var scope = _transactionScopeFactory.Create(_dbContext))
                {
                    await _commandExecutor.ExecuteAsync(new DeleteUnstructuredDataDependenciesCommand(PageEntityDefinition.DefinitionCode, command.PageId), executionContext);

                    await _dbContext.SaveChangesAsync();

                    await _pageStoredProcedures.UpdatePublishStatusQueryLookupAsync(command.PageId);

                    scope.Complete();
                }
                _pageCache.Clear(command.PageId);

                await _messageAggregator.PublishAsync(new PageDeletedMessage()
                {
                    PageId = command.PageId
                });
            }
        }
Exemple #3
0
        public async Task ExecuteAsync(DeletePageDraftVersionCommand command, IExecutionContext executionContext)
        {
            var draft = await _dbContext
                        .PageVersions
                        .SingleOrDefaultAsync(v => v.PageId == command.PageId &&
                                              v.WorkFlowStatusId == (int)WorkFlowStatus.Draft &&
                                              !v.IsDeleted);

            if (draft != null)
            {
                var versionId = draft.PageVersionId;
                draft.IsDeleted = true;
                using (var scope = _transactionScopeFactory.Create(_dbContext))
                {
                    await _commandExecutor.ExecuteAsync(new DeleteUnstructuredDataDependenciesCommand(PageVersionEntityDefinition.DefinitionCode, draft.PageVersionId), executionContext);

                    await _dbContext.SaveChangesAsync();

                    await _pageStoredProcedures.UpdatePublishStatusQueryLookupAsync(command.PageId);

                    scope.Complete();
                }
                _pageCache.Clear(command.PageId);

                await _messageAggregator.PublishAsync(new PageDraftVersionDeletedMessage()
                {
                    PageId        = command.PageId,
                    PageVersionId = versionId
                });
            }
        }
        public async Task ExecuteAsync(UpdatePageDraftVersionCommand command, IExecutionContext executionContext)
        {
            var draft = await GetDraftVersion(command.PageId).SingleOrDefaultAsync();

            using (var scope = _transactionScopeFactory.Create())
            {
                draft = await CreateDraftIfRequiredAsync(command.PageId, draft);

                UpdateDraft(command, draft);

                await _dbContext.SaveChangesAsync();

                scope.Complete();
            }
            _pageCache.Clear(command.PageId);

            await _messageAggregator.PublishAsync(new PageDraftVersionUpdatedMessage()
            {
                PageId        = command.PageId,
                PageVersionId = draft.PageVersionId
            });

            if (command.Publish)
            {
                await _commandExecutor.ExecuteAsync(new PublishPageCommand(draft.PageId));
            }
        }
        public async Task ExecuteAsync(UnPublishPageCommand command, IExecutionContext executionContext)
        {
            var pageVersions = await _dbContext
                               .PageVersions
                               .Where(p => p.PageId == command.PageId &&
                                      !p.IsDeleted &&
                                      !p.Page.IsDeleted &&
                                      (p.WorkFlowStatusId == (int)WorkFlowStatus.Published || p.WorkFlowStatusId == (int)WorkFlowStatus.Draft))
                               .ToListAsync();

            var publishedVersion = pageVersions.SingleOrDefault(p => p.WorkFlowStatusId == (int)WorkFlowStatus.Published);

            EntityNotFoundException.ThrowIfNull(publishedVersion, command.PageId);

            if (pageVersions.Any(p => p.WorkFlowStatusId == (int)WorkFlowStatus.Draft))
            {
                // If there's already a draft, change to approved.
                publishedVersion.WorkFlowStatusId = (int)WorkFlowStatus.Approved;
            }
            else
            {
                // Else set it to draft
                publishedVersion.WorkFlowStatusId = (int)WorkFlowStatus.Draft;
            }

            await _dbContext.SaveChangesAsync();

            _pageCache.Clear();

            await _messageAggregator.PublishAsync(new PageUnPublishedMessage()
            {
                PageId = command.PageId
            });
        }
Exemple #6
0
        public async Task ExecuteAsync(PublishPageCommand command, IExecutionContext executionContext)
        {
            var pageVersions = await QueryVersions(command).ToListAsync();

            using (var scope = _transactionScopeFactory.Create())
            {
                // Find the published one and make it appPageroved
                var publishedVersion = pageVersions.SingleOrDefault(v => v.WorkFlowStatusId == (int)WorkFlowStatus.Published);
                if (publishedVersion != null)
                {
                    publishedVersion.WorkFlowStatusId = (int)WorkFlowStatus.Approved;
                    await _dbContext.SaveChangesAsync();
                }

                // Find the draft page and make it published
                SetDraftVersionPublished(command, pageVersions);
                await _dbContext.SaveChangesAsync();

                scope.Complete();
            }

            _pageCache.Clear();

            await _messageAggregator.PublishAsync(new PagePublishedMessage()
            {
                PageId = command.PageId
            });
        }
        private Task OnTransactionComplete(UpdatePageAccessRuleSetCommand command)
        {
            _pageCache.Clear(command.PageId);

            return(_messageAggregator.PublishAsync(new PageAccessRulesUpdatedMessage()
            {
                PageId = command.PageId
            }));
        }
Exemple #8
0
        private Task OnTransactionComplete(UnPublishPageCommand command)
        {
            _pageCache.Clear();

            return(_messageAggregator.PublishAsync(new PageUnPublishedMessage()
            {
                PageId = command.PageId
            }));
        }
        private Task OnTransactionComplete(int pageId, int pageVersionBlockId)
        {
            _pageCache.Clear(pageId);

            return(_messageAggregator.PublishAsync(new PageVersionBlockMovedMessage()
            {
                PageId = pageId,
                PageVersionBlockId = pageVersionBlockId
            }));
        }
        private Task OnTransactionComplete(UpdatePageUrlCommand command, bool isPublished)
        {
            _pageCache.Clear(command.PageId);

            return(_messageAggregator.PublishAsync(new PageUrlChangedMessage()
            {
                PageId = command.PageId,
                HasPublishedVersionChanged = isPublished
            }));
        }
        private Task OnTransactionComplete(PageRoute page)
        {
            _pageCache.Clear(page.PageId);

            return(_messageAggregator.PublishAsync(new PageDeletedMessage()
            {
                PageId = page.PageId,
                FullUrlPath = page.FullUrlPath
            }));
        }
Exemple #12
0
        private Task OnTransactionComplete(PageVersion draft)
        {
            _pageCache.Clear(draft.PageId);

            return(_messageAggregator.PublishAsync(new PageDraftVersionUpdatedMessage()
            {
                PageId = draft.PageId,
                PageVersionId = draft.PageVersionId
            }));
        }
        private Task OnTransactionComplete(AddPageDraftVersionCommand command, int newVersionId)
        {
            _pageCache.Clear(command.PageId);

            return(_messageAggregator.PublishAsync(new PageDraftVersionAddedMessage()
            {
                PageId = command.PageId,
                PageVersionId = newVersionId
            }));
        }
        private Task OnTransactionComplete(PageVersion pageVersion, PageVersionBlock newBlock)
        {
            _pageCache.Clear(pageVersion.PageId);

            return(_messageAggregator.PublishAsync(new PageVersionBlockAddedMessage()
            {
                PageId = pageVersion.PageId,
                PageVersionBlockId = newBlock.PageVersionBlockId
            }));
        }
        private Task OnTransactionComplete(Page page)
        {
            _pageCache.Clear(page.PageId);

            return(_messageAggregator.PublishAsync(new PageUpdatedMessage()
            {
                PageId = page.PageId,
                HasPublishedVersionChanged = page.PublishStatusCode == PublishStatusCode.Published
            }));
        }
Exemple #16
0
        private Task OnTransactionComplete(PageRoute oldPageRoute, bool isPublished)
        {
            _pageCache.Clear(oldPageRoute.PageId);

            return(_messageAggregator.PublishAsync(new PageUrlChangedMessage()
            {
                PageId = oldPageRoute.PageId,
                OldFullUrlPath = oldPageRoute.FullUrlPath,
                HasPublishedVersionChanged = isPublished
            }));
        }
        public void Execute(AddPageDraftVersionCommand command, IExecutionContext executionContext)
        {
            var newVersionId = _entityFrameworkSqlExecutor
                               .ExecuteCommandWithOutput <int?>("Cofoundry.Page_AddDraft",
                                                                "PageVersionId",
                                                                new SqlParameter("PageId", command.PageId),
                                                                new SqlParameter("CopyFromPageVersionId", command.CopyFromPageVersionId),
                                                                new SqlParameter("CreateDate", executionContext.ExecutionDate),
                                                                new SqlParameter("CreatorId", executionContext.UserContext.UserId)
                                                                );

            if (!newVersionId.HasValue)
            {
                throw new UnexpectedSqlStoredProcedureResultException("Cofoundry.Page_AddDraft", "No PageId was returned.");
            }

            _pageCache.Clear(newVersionId.Value);

            // Set Ouput
            command.OutputPageVersionId = newVersionId.Value;
        }
        public async Task ExecuteAsync(UnPublishPageCommand command, IExecutionContext executionContext)
        {
            var page = await _dbContext
                       .Pages
                       .FilterActive()
                       .FilterByPageId(command.PageId)
                       .SingleOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(page, command.PageId);

            if (page.PublishStatusCode == PublishStatusCode.Unpublished)
            {
                // No action
                return;
            }

            var version = await _dbContext
                          .PageVersions
                          .Include(p => p.Page)
                          .Where(v => v.PageId == command.PageId &&
                                 !v.IsDeleted &&
                                 !v.Page.IsDeleted &&
                                 (v.WorkFlowStatusId == (int)WorkFlowStatus.Draft || v.WorkFlowStatusId == (int)WorkFlowStatus.Published))
                          .OrderByDescending(v => v.WorkFlowStatusId == (int)WorkFlowStatus.Draft)
                          .ThenByDescending(v => v.CreateDate)
                          .FirstOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(version, command.PageId);

            page.PublishStatusCode   = PublishStatusCode.Unpublished;
            version.WorkFlowStatusId = (int)WorkFlowStatus.Draft;

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

                await _pageStoredProcedures.UpdatePublishStatusQueryLookupAsync(command.PageId);

                scope.Complete();
            }

            _pageCache.Clear();

            await _messageAggregator.PublishAsync(new PageUnPublishedMessage()
            {
                PageId = command.PageId
            });
        }
Exemple #19
0
        public async Task ExecuteAsync(UpdatePageCommand command, IExecutionContext executionContext)
        {
            var page = await GetPageById(command.PageId).SingleOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(page, command.PageId);

            MapPage(command, executionContext, page);
            await _dbContext.SaveChangesAsync();

            _pageCache.Clear(command.PageId);

            await _messageAggregator.PublishAsync(new PageUpdatedMessage()
            {
                PageId = command.PageId,
                HasPublishedVersionChanged = page.PublishStatusCode == PublishStatusCode.Published
            });
        }
Exemple #20
0
        public async Task ExecuteAsync(PublishPageCommand command, IExecutionContext executionContext)
        {
            var version = await _dbContext
                          .PageVersions
                          .Include(p => p.Page)
                          .Where(v => v.PageId == command.PageId &&
                                 !v.IsDeleted &&
                                 !v.Page.IsDeleted &&
                                 (v.WorkFlowStatusId == (int)WorkFlowStatus.Draft || v.WorkFlowStatusId == (int)WorkFlowStatus.Published))
                          .OrderByDescending(v => v.WorkFlowStatusId == (int)WorkFlowStatus.Draft)
                          .ThenByDescending(v => v.CreateDate)
                          .FirstOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(version, command.PageId);

            UpdatePublishDate(command, executionContext, version);

            if (version.WorkFlowStatusId == (int)WorkFlowStatus.Published)
            {
                // only thing we can do with a published version is update the date
                await _dbContext.SaveChangesAsync();
            }
            else
            {
                version.WorkFlowStatusId       = (int)WorkFlowStatus.Published;
                version.Page.PublishStatusCode = PublishStatusCode.Published;

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

                    await _pageStoredProcedures.UpdatePublishStatusQueryLookupAsync(command.PageId);

                    scope.Complete();
                }
            }

            _pageCache.Clear();

            await _messageAggregator.PublishAsync(new PagePublishedMessage()
            {
                PageId = command.PageId
            });
        }
Exemple #21
0
        public async Task ExecuteAsync(AddPageDraftVersionCommand command, IExecutionContext executionContext)
        {
            var newVersionId = await _pageStoredProcedures.AddDraftAsync(
                command.PageId,
                command.CopyFromPageVersionId,
                executionContext.ExecutionDate,
                executionContext.UserContext.UserId.Value);

            _pageCache.Clear(command.PageId);

            // Set Ouput
            command.OutputPageVersionId = newVersionId;

            await _messageAggregator.PublishAsync(new PageDraftVersionAddedMessage()
            {
                PageId        = command.PageId,
                PageVersionId = newVersionId
            });
        }
Exemple #22
0
        public async Task ExecuteAsync(RegisterPageTemplatesCommand command, IExecutionContext executionContext)
        {
            var dbPageTemplates = await _dbContext
                                  .PageTemplates
                                  .Include(t => t.PageTemplateSections)
                                  .ToDictionaryAsync(d => d.FileName);

            var fileTemplates = _pageTemplateViewFileLocator
                                .GetPageTemplateFiles();

            DetectDuplicateTemplates(fileTemplates);

            // Mark removed templates as deleted
            await DeleteTemplates(executionContext, dbPageTemplates, fileTemplates);
            await UpdateTemplates(executionContext, dbPageTemplates, fileTemplates);

            // Save changes
            await _dbContext.SaveChangesAsync();

            _pageCache.Clear();
        }
Exemple #23
0
        public async Task ExecuteAsync(RegisterPageModuleTypesCommand command, IExecutionContext executionContext)
        {
            var dbPageModules = await _dbContext
                                .PageModuleTypes
                                .Include(t => t.PageModuleTemplates)
                                .ToDictionaryAsync(d => d.FileName);

            DetectDuplicateModules();

            var moduleDataModels = _allPageModuleDataModels
                                   .ToDictionary(m => FormatModuleFileName(m));

            await DeleteModules(executionContext, dbPageModules, moduleDataModels);

            await UpdateModulesAsync(executionContext, dbPageModules, moduleDataModels);

            await _dbContext.SaveChangesAsync();

            _pageCache.Clear();
            _moduleCache.Clear();
        }
        public async Task ExecuteAsync(DeletePageVersionModuleCommand command, IExecutionContext executionContext)
        {
            var dbResult = await _dbContext
                           .PageVersionModules
                           .Where(p => p.PageVersionModuleId == command.PageVersionModuleId)
                           .Select(p => new
            {
                Module           = p,
                PageId           = p.PageVersion.PageId,
                WorkFlowStatusId = p.PageVersion.WorkFlowStatusId
            })
                           .SingleOrDefaultAsync();

            if (dbResult != null)
            {
                if (dbResult.WorkFlowStatusId != (int)WorkFlowStatus.Draft)
                {
                    throw new NotPermittedException("Page modules cannot be deleted unless the page version is in draft status");
                }

                var versionId = dbResult.Module.PageVersionId;
                using (var scope = _transactionScopeFactory.Create())
                {
                    await _commandExecutor.ExecuteAsync(new DeleteUnstructuredDataDependenciesCommand(PageVersionModuleEntityDefinition.DefinitionCode, dbResult.Module.PageVersionModuleId));

                    _dbContext.PageVersionModules.Remove(dbResult.Module);
                    await _dbContext.SaveChangesAsync();

                    scope.Complete();
                }
                _pageCache.Clear(dbResult.PageId);

                await _messageAggregator.PublishAsync(new PageVersionModuleDeletedMessage()
                {
                    PageId        = dbResult.PageId,
                    PageVersionId = versionId
                });
            }
        }
        public async Task ExecuteAsync(AddPageVersionBlockCommand command, IExecutionContext executionContext)
        {
            var templateRegion = await _dbContext
                                 .PageTemplateRegions
                                 .FirstOrDefaultAsync(l => l.PageTemplateRegionId == command.PageTemplateRegionId);

            EntityNotFoundException.ThrowIfNull(templateRegion, command.PageTemplateRegionId);

            var pageVersion = _dbContext
                              .PageVersions
                              .Include(s => s.PageVersionBlocks)
                              .FirstOrDefault(v => v.PageVersionId == command.PageVersionId);

            EntityNotFoundException.ThrowIfNull(pageVersion, command.PageVersionId);

            if (pageVersion.WorkFlowStatusId != (int)WorkFlowStatus.Draft)
            {
                throw new NotPermittedException("Page blocks cannot be added unless the page version is in draft status");
            }

            var pageVersionBlocks = pageVersion
                                    .PageVersionBlocks
                                    .Where(m => m.PageTemplateRegionId == templateRegion.PageTemplateRegionId);

            PageVersionBlock adjacentItem = null;

            if (command.AdjacentVersionBlockId.HasValue)
            {
                adjacentItem = pageVersionBlocks
                               .SingleOrDefault(m => m.PageVersionBlockId == command.AdjacentVersionBlockId);
                EntityNotFoundException.ThrowIfNull(adjacentItem, command.AdjacentVersionBlockId);
            }

            var newBlock = new PageVersionBlock();

            newBlock.PageTemplateRegion = templateRegion;

            await _pageBlockCommandHelper.UpdateModelAsync(command, newBlock);

            newBlock.PageVersion = pageVersion;
            newBlock.UpdateDate  = executionContext.ExecutionDate;

            _entityAuditHelper.SetCreated(newBlock, executionContext);
            _entityOrderableHelper.SetOrderingForInsert(pageVersionBlocks, newBlock, command.InsertMode, adjacentItem);

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

                var dependencyCommand = new UpdateUnstructuredDataDependenciesCommand(
                    PageVersionBlockEntityDefinition.DefinitionCode,
                    newBlock.PageVersionBlockId,
                    command.DataModel);

                await _commandExecutor.ExecuteAsync(dependencyCommand, executionContext);

                scope.Complete();
            }
            _pageCache.Clear(pageVersion.PageId);

            command.OutputPageBlockId = newBlock.PageVersionBlockId;

            await _messageAggregator.PublishAsync(new PageVersionBlockAddedMessage()
            {
                PageId             = pageVersion.PageId,
                PageVersionBlockId = newBlock.PageVersionBlockId
            });
        }
Exemple #26
0
        public async Task ExecuteAsync(UpdatePageVersionModuleCommand command, IExecutionContext executionContext)
        {
            var dbModule = await _dbContext
                           .PageVersionModules
                           .Include(m => m.PageModuleTypeTemplate)
                           .Include(m => m.PageModuleType)
                           .Include(m => m.PageVersion)
                           .Where(l => l.PageVersionModuleId == command.PageVersionModuleId)
                           .SingleOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(dbModule, command.PageVersionModuleId);

            if (dbModule.PageVersion.WorkFlowStatusId != (int)WorkFlowStatus.Draft)
            {
                throw new NotPermittedException("Page modules cannot be updated unless the page version is in draft status");
            }

            if (command.PageModuleTypeId != dbModule.PageModuleTypeId)
            {
                var pageModuleType = await _dbContext
                                     .PageModuleTypes
                                     .Where(m => m.PageModuleTypeId == command.PageModuleTypeId)
                                     .SingleOrDefaultAsync();

                EntityNotFoundException.ThrowIfNull(pageModuleType, command.PageModuleTypeId);
                dbModule.PageModuleType = pageModuleType;
            }

            dbModule.SerializedData = _dbUnstructuredDataSerializer.Serialize(command.DataModel);
            dbModule.UpdateDate     = executionContext.ExecutionDate;

            if (command.PageModuleTypeTemplateId != dbModule.PageModuleTypeTemplateId && command.PageModuleTypeTemplateId.HasValue)
            {
                dbModule.PageModuleTypeTemplate = await _dbContext
                                                  .PageModuleTypeTemplates
                                                  .SingleOrDefaultAsync(m => m.PageModuleTypeId == dbModule.PageModuleTypeId && m.PageModuleTypeTemplateId == command.PageModuleTypeTemplateId);

                EntityNotFoundException.ThrowIfNull(dbModule.PageModuleTypeTemplate, command.PageModuleTypeTemplateId);
            }
            else if (command.PageModuleTypeTemplateId != dbModule.PageModuleTypeTemplateId)
            {
                dbModule.PageModuleTypeTemplate = null;
            }

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

                var dependencyCommand = new UpdateUnstructuredDataDependenciesCommand(
                    PageVersionModuleEntityDefinition.DefinitionCode,
                    dbModule.PageVersionModuleId,
                    command.DataModel);

                await _commandExecutor.ExecuteAsync(dependencyCommand);

                scope.Complete();
            }
            _pageCache.Clear(dbModule.PageVersion.PageId);

            await _messageAggregator.PublishAsync(new PageVersionModuleUpdatedMessage()
            {
                PageId = dbModule.PageVersion.PageId,
                PageVersionModuleId = command.PageVersionModuleId
            });
        }
Exemple #27
0
 /// <summary>
 /// Clears all items in the web directory cache. This also clears out
 /// the pages cache because page routes are dependent on web directories.
 /// </summary>
 public void Clear()
 {
     _cache.Clear();
     _pageCache.Clear();
 }
Exemple #28
0
        public async Task ExecuteAsync(MovePageVersionModuleCommand command, IExecutionContext executionContext)
        {
            var dbResult = await _dbContext
                           .PageVersionModules
                           .Where(m => m.PageVersionModuleId == command.PageVersionModuleId)
                           .Select(m => new
            {
                Module           = m,
                PageId           = m.PageVersion.PageId,
                WorkFlowStatusId = m.PageVersion.WorkFlowStatusId
            })
                           .SingleOrDefaultAsync();

            EntityNotFoundException.ThrowIfNull(dbResult, command.PageVersionModuleId);

            if (dbResult.WorkFlowStatusId != (int)WorkFlowStatus.Draft)
            {
                throw new NotPermittedException("Page modules cannot be moved unless the page version is in draft status");
            }

            var module = dbResult.Module;
            var moduleToSwapWithQuery = _dbContext
                                        .PageVersionModules
                                        .Where(p => p.PageTemplateSectionId == module.PageTemplateSectionId && p.PageVersionId == module.PageVersionId);

            PageVersionModule moduleToSwapWith;

            switch (command.Direction)
            {
            case OrderedItemMoveDirection.Up:
                moduleToSwapWith = await moduleToSwapWithQuery
                                   .Where(p => p.Ordering < module.Ordering)
                                   .OrderByDescending(p => p.Ordering)
                                   .FirstOrDefaultAsync();

                break;

            case OrderedItemMoveDirection.Down:
                moduleToSwapWith = await moduleToSwapWithQuery
                                   .Where(p => p.Ordering > module.Ordering)
                                   .OrderBy(p => p.Ordering)
                                   .FirstOrDefaultAsync();

                break;

            default:
                throw new InvalidOperationException("OrderedItemMoveDirection not recognised: " + command.Direction);
            }

            if (moduleToSwapWith == null)
            {
                return;
            }

            int oldOrdering = module.Ordering;

            module.Ordering             = moduleToSwapWith.Ordering;
            module.UpdateDate           = executionContext.ExecutionDate;
            moduleToSwapWith.Ordering   = oldOrdering;
            moduleToSwapWith.UpdateDate = executionContext.ExecutionDate;

            await _dbContext.SaveChangesAsync();

            _pageCache.Clear(dbResult.PageId);

            await _messageAggregator.PublishAsync(new PageVersionModuleMovedMessage()
            {
                PageId = dbResult.PageId,
                PageVersionModuleId = command.PageVersionModuleId
            });
        }