Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nul800sebastiaan/ca61d2eccc3faa4f6ba5 to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/ca61d2eccc3faa4f6ba5 to your computer and use it in GitHub Desktop.
Update through ContentService
using System.Configuration;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using Umbraco.Web.UI.Umbraco.Controls;
namespace My.Controllers
{
public class MyUpdateController : SurfaceController
{
public ActionResult Create(SomeModel model)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
var contentService = Services.ContentService;
var currentPageId= UmbracoContext.PageId.Value;
var content = contentService.GetById(currentPageId);
content.SetValue("myProp", model.MyProp);
contentService.PublishWithStatus(content);
return RedirectToCurrentUmbracoPage();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment