/// <summary> /// 公共部分编辑 /// </summary> /// <returns></returns> private ActionResult EditPost(int id, Action <ContentItem> conditionallyPublish) { var contentItem = TomeltServices.ContentManager.Get(id, VersionOptions.DraftRequired); if (contentItem == null) { return(Json(new { State = 0, Msg = T("此内容不存在").Text })); } if (!TomeltServices.Authorizer.Authorize(ArticleManagePermissions.EditContent, contentItem, T("无编辑权限"))) { return(Json(new { State = 0, Msg = T("无编辑权限").Text })); } //string previousRoute = null; //if (contentItem.Has<IAliasAspect>() // && !string.IsNullOrWhiteSpace(returnUrl) // && Request.IsLocalUrl(returnUrl) // // only if the original returnUrl is the content itself // && String.Equals(returnUrl, Url.ItemDisplayUrl(contentItem), StringComparison.OrdinalIgnoreCase) //) //{ // previousRoute = contentItem.As<IAliasAspect>().Path; //} TomeltServices.ContentManager.UpdateEditor(contentItem, this); if (!ModelState.IsValid) { TransactionManager.Cancel(); return(Json(new { State = 0, Msg = T("数据校验失败,请核实输入的数据是否正确").Text })); } conditionallyPublish(contentItem); return(Json(new { State = 1, Msg = T("编辑成功").Text })); }
private ActionResult CreatePost(string typeId, Action <ContentItem> conditionallyPublish) { var contentItem = TomeltServices.ContentManager.New(typeId); if (!TomeltServices.Authorizer.Authorize(ArticleManagePermissions.EditContent, contentItem, T("无创建权限"))) { return(Json(new { State = 0, Msg = T("无创建权限").Text })); } TomeltServices.ContentManager.Create(contentItem, VersionOptions.Draft); TomeltServices.ContentManager.UpdateEditor(contentItem, this); if (!ModelState.IsValid) { TransactionManager.Cancel(); return(Json(new { State = 0, Msg = T("数据校验失败,请核实输入的数据是否正确").Text })); } conditionallyPublish(contentItem); return(Json(new { State = 1, Msg = T("创建成功").Text })); }