コード例 #1
0
        private async Task <CustomEntityVersion> CreateDraftIfRequiredAsync(
            UpdateCustomEntityDraftVersionCommand command,
            CustomEntityVersion draft,
            IExecutionContext executionContext
            )
        {
            if (draft != null)
            {
                return(draft);
            }

            var addDraftCommand = new AddCustomEntityDraftVersionCommand();

            addDraftCommand.CustomEntityId = command.CustomEntityId;
            await _commandExecutor.ExecuteAsync(addDraftCommand, executionContext);

            return(await GetDraftVersionAsync(command));
        }
コード例 #2
0
 public async Task <IActionResult> Post([FromBody] AddCustomEntityDraftVersionCommand command)
 {
     return(await _apiResponseHelper.RunCommandAsync(this, command));
 }
コード例 #3
0
 public Task <JsonResult> Post([FromBody] AddCustomEntityDraftVersionCommand command)
 {
     return(_apiResponseHelper.RunCommandAsync(command));
 }
コード例 #4
0
        public async Task ExecuteAsync(Controller controller, PageActionRoutingState state)
        {
            var pageRoutingInfo = state.PageRoutingInfo;

            if (pageRoutingInfo == null)
            {
                return;
            }

            // If there's no draft version and we're in edit mode for 'Pages' then
            // create one and re-run the query
            var publishStatus = state.VisualEditorState.GetPublishStatusQuery();

            if (!state.InputParameters.IsEditingCustomEntity &&
                publishStatus != PublishStatusQuery.Published &&
                publishStatus != PublishStatusQuery.SpecificVersion &&
                state.IsCofoundryAdminUser)
            {
                var versionRouting = pageRoutingInfo.PageRoute.Versions.GetVersionRouting(publishStatus);
                if (versionRouting == null)
                {
                    var command = new AddPageDraftVersionCommand()
                    {
                        PageId = pageRoutingInfo.PageRoute.PageId
                    };
                    await _commandExecutor.ExecuteAsync(command, state.CofoundryAdminExecutionContext);

                    var pageQuery = GetPageRoutingInfoQuery(state);
                    pageRoutingInfo = await _queryExecutor.ExecuteAsync(pageQuery);
                }
            }

            if (pageRoutingInfo.CustomEntityRoute != null &&
                pageRoutingInfo.PageRoute.PageType == PageType.CustomEntityDetails)
            {
                var correctUrl = pageRoutingInfo.CustomEntityRouteRule.MakeUrl(pageRoutingInfo.PageRoute, pageRoutingInfo.CustomEntityRoute);
                if (!state.InputParameters.Path.Equals(correctUrl.TrimStart('/'), StringComparison.OrdinalIgnoreCase))
                {
                    Debug.WriteLine("Incorrect Custom Entity Url detected, redirecting from " + state.InputParameters.Path + " to " + correctUrl);
                    state.Result = new RedirectResult(correctUrl, true);
                }
                else if (state.InputParameters.IsEditingCustomEntity &&
                         publishStatus != PublishStatusQuery.Published &&
                         publishStatus != PublishStatusQuery.SpecificVersion &&
                         state.IsCofoundryAdminUser)
                {
                    var versionRouting = pageRoutingInfo.CustomEntityRoute.Versions.GetVersionRouting(publishStatus);
                    if (versionRouting == null)
                    {
                        // if no draft version for route, add one.
                        var addDraftVersionCommand = new AddCustomEntityDraftVersionCommand()
                        {
                            CustomEntityId = pageRoutingInfo.CustomEntityRoute.CustomEntityId
                        };
                        await _commandExecutor.ExecuteAsync(addDraftVersionCommand, state.CofoundryAdminExecutionContext);

                        var pageQuery = GetPageRoutingInfoQuery(state);
                        pageRoutingInfo = await _queryExecutor.ExecuteAsync(pageQuery);
                    }
                }
            }

            state.PageRoutingInfo = pageRoutingInfo;
        }
コード例 #5
0
        public async Task <int> AddDraftAsync(AddCustomEntityDraftVersionCommand command)
        {
            await ExtendableContentRepository.ExecuteCommandAsync(command);

            return(command.CustomEntityId);
        }