Exemplo n.º 1
0
        public async Task AddEntriesAsync(IEnumerable <WorkflowRoutesEntry> entries)
        {
            var document = await LoadDocumentAsync();

            AddEntries(document, entries);
            await _documentManager.UpdateAsync(document);
        }
Exemplo n.º 2
0
        public async Task UpdateEntriesAsync()
        {
            await EnsureInitializedAsync();

            // Update the cache with a new state and then refresh entries as it would be done on a next request.
            await _autorouteStateManager.UpdateAsync(new AutorouteStateDocument(), afterUpdateAsync : RefreshEntriesAsync);
        }
Exemplo n.º 3
0
        private Task UpdateAsync(ContentItem contentItem)
        {
            var layerMetadata = contentItem.As <LayerMetadata>();

            if (layerMetadata == null)
            {
                return(Task.CompletedTask);
            }

            // Checked by the 'LayerFilter'.
            return(_layerStateManager.UpdateAsync(new LayerState()));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> UpdatePosition(string contentItemId, double position, string zone)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageLayers))
            {
                return(StatusCode(401));
            }

            // Load the latest version first if any
            var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest);

            if (contentItem == null)
            {
                return(StatusCode(404));
            }

            var layerMetadata = contentItem.As <LayerMetadata>();

            if (layerMetadata == null)
            {
                return(StatusCode(403));
            }

            layerMetadata.Position = position;
            layerMetadata.Zone     = zone;

            contentItem.Apply(layerMetadata);

            _session.Save(contentItem);

            // In case the moved contentItem is the draft for a published contentItem we update it's position too.
            // We do that because we want the position of published and draft version to be the same.
            if (contentItem.IsPublished() == false)
            {
                var publishedContentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Published);

                if (publishedContentItem != null)
                {
                    layerMetadata = contentItem.As <LayerMetadata>();

                    if (layerMetadata == null)
                    {
                        return(StatusCode(403));
                    }

                    layerMetadata.Position = position;
                    layerMetadata.Zone     = zone;

                    publishedContentItem.Apply(layerMetadata);

                    _session.Save(publishedContentItem);
                }
            }

            // The state will be updated once the ambient session is committed.
            await _layerStateManager.UpdateAsync(new LayerState());

            if (Request.Headers != null && Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                return(StatusCode(200));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }