Ejemplo n.º 1
0
        public ActionResult RewriterSaveAllPost(RewriterViewModel rewriterViewModel, IEnumerable <int> itemIds)
        {
            foreach (var itemId in itemIds)
            {
                var item = _contentManager.Get(itemId, VersionOptions.DraftRequired);
                _prefixedEditorManager.UpdateEditor(item, this);
                _contentManager.Publish(item);
            }

            // This would be better, but: http://orchard.codeplex.com/workitem/18979
            //foreach (var item in _contentManager.GetMany<IContent>(itemIds, VersionOptions.DraftRequired, QueryHints.Empty)) {
            //    _prefixedEditorManager.UpdateEditor(item, this);
            //    _contentManager.Publish(item.ContentItem);
            //}

            return(RedirectToAction("Rewriter", ControllerContext.RouteData.Values));
        }
        /// <summary>
        /// Updates contents whose editor was previously built with IPrefixedEditorManager with the updater
        /// </summary>
        /// <param name="contents">The content objects to use</param>
        /// <param name="updater">The updater to update the contents with</param>
        /// <param name="groupId">Optional editor group ID</param>
        /// <returns>The updated editor shapes</returns>
        public static IEnumerable <dynamic> UpdateEditors(this IPrefixedEditorManager prefixedEditorManager, IEnumerable <IContent> contents, IUpdateModel updater, string groupId = "")
        {
            var shapes = new List <dynamic>();

            foreach (var content in contents)
            {
                shapes.Add(prefixedEditorManager.UpdateEditor(content, updater, groupId));
            }

            return(shapes);
        }
        /// <summary>
        /// Updates contents whose editor was previously built with IPrefixedEditorManager with the updater
        /// </summary>
        /// <param name="contents">The content objects to use</param>
        /// <param name="prefixedParents">To be used if the contents' editor was wrapped into the prefixed editor of parents. Specify all the parents, starting from the outer most for each item.</param>
        /// <param name="updater">The updater to update the contents with</param>
        /// <param name="groupId">Optional editor group ID</param>
        /// <returns>The updated editor shapes</returns>
        public static IEnumerable <dynamic> UpdateEditors(this IPrefixedEditorManager prefixedEditorManager, IEnumerable <IContent> contents, IEnumerable <IEnumerable <IPrefixedParent> > prefixedParents, IUpdateModel updater, string groupId = "")
        {
            var shapes  = new List <dynamic>();
            var parents = prefixedParents.ToList();

            if (contents.Count() != parents.Count)
            {
                throw new InvalidOperationException("The number of contents and parents should be the same.");
            }

            int i = 0;

            foreach (var content in contents)
            {
                shapes.Add(prefixedEditorManager.UpdateEditor(content, parents[i++], updater, groupId));
            }

            return(shapes);
        }