diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index a5920ea5ef..31c730dd45 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -820,7 +820,7 @@ namespace umbraco.cms.businesslogic.web } /// - /// Publishing a document + /// Saves and Publishes a document. /// A xmlrepresentation of the document and its data are exposed to the runtime data /// (an xmlrepresentation is added -or updated if the document previously are published) , /// this will lead to a new version of the document being created, for continuing editing of @@ -830,7 +830,7 @@ namespace umbraco.cms.businesslogic.web [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.Publish()", false)] public void Publish(User u) { - ApplicationContext.Current.Services.ContentService.Publish(Content, u.Id, true); + SaveAndPublish(u); } /// @@ -850,7 +850,7 @@ namespace umbraco.cms.businesslogic.web if (!e.Cancel) { - var result = ApplicationContext.Current.Services.ContentService.Publish(Content, u.Id); + var result = ApplicationContext.Current.Services.ContentService.Publish(Content, u.Id, true); _published = result; FireAfterPublish(e); @@ -951,6 +951,38 @@ namespace umbraco.cms.businesslogic.web } } + /// + /// Saves and publishes a document + /// + /// The usercontext under which the action are performed + /// + public bool SaveAndPublish(User u) + { + var e = new SaveEventArgs(); + + foreach (var property in GenericProperties) + { + Content.SetValue(property.PropertyType.Alias, property.Value); + } + + FireBeforeSave(e); + + if (!e.Cancel) + { + var result = ApplicationContext.Current.Services.ContentService.SaveAndPublish(Content, u.Id, true); + + base.Save(); + // update preview xml + SaveXmlPreview(new XmlDocument()); + + FireAfterSave(e); + + return result; + } + + return false; + } + [Obsolete("Deprecated, Use Umbraco.Core.Services.ContentService.HasPublishedVersion()", false)] public bool HasPublishedVersion() {