Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MvcCourse.Core.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Web.Mvc;
- using Umbraco.Web.Mvc;
- using Umbraco.Web.PublishedContentModels;
- namespace MvcCourse.Core.Controllers
- {
- public class DocumentationFormController : SurfaceController
- {
- [ChildActionOnly]
- public ActionResult Render(Documentation model)
- {
- var documentationFormModel = new DocumentationFormModel()
- {
- Name = model.Name,
- BodyText = model.BodyText.ToString()
- };
- return PartialView("~/Views/Partials/DocumentationForm.cshtml", documentationFormModel);
- }
- [HttpPost]
- public ActionResult Submit(DocumentationFormModel model)
- {
- if (ModelState.IsValid == false)
- {
- return CurrentUmbracoPage();
- }
- var currentPageId = CurrentPage.Id;
- var contentService = Services.ConsentService;
- var content = contentService.GetById(currentPageId);
- content.Name = model.Name;
- var bodyTextProperty = Documentation.GetModelPropertyType(d => d.BodyText);
- content.SetValue(bodyTextProperty.PropertyTypeAlias, model.BodyText);
- contentService.SaveAndPublishWithStatus(content);
- return RedirectToCurrentUmbracoPage();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement