private PageVersion CreateDraftIfRequired(int pageId, PageVersion draft)
        {
            if (draft != null)
            {
                return(draft);
            }

            var command = new AddPageDraftVersionCommand();

            command.PageId = pageId;
            _commandExecutor.Execute(command);

            return(GetDraftVersion(pageId).SingleOrDefault());
        }
        private async Task <PageVersion> CreateDraftIfRequiredAsync(int pageId, PageVersion draft)
        {
            if (draft != null)
            {
                return(draft);
            }

            var command = new AddPageDraftVersionCommand();

            command.PageId = pageId;
            await _commandExecutor.ExecuteAsync(command);

            return(await GetDraftVersion(pageId).SingleOrDefaultAsync());
        }
Пример #3
0
        /// <summary>
        /// Creates a new draft version of a page from the currently published version. If there
        /// isn't a currently published version then an exception will be thrown. An exception is also
        /// thrown if there is already a draft version.
        /// </summary>
        /// <param name="command">Command parameters.</param>
        /// <param name="executionContext">Optional execution context to use when executing the command. Useful if you need to temporarily elevate your permission level.</param>
        public async Task <int> AddPageDraftVersionAsync(AddPageDraftVersionCommand command, IExecutionContext executionContext = null)
        {
            await _commandExecutor.ExecuteAsync(command, executionContext);

            return(command.OutputPageVersionId);
        }
        public async Task <int> AddDraftAsync(AddPageDraftVersionCommand command)
        {
            await ExtendableContentRepository.ExecuteCommandAsync(command);

            return(command.OutputPageVersionId);
        }