public ActionResult _Reproduce(string spaceKey, long threadId) { BlogThread blogThread = blogService.Get(threadId); if (blogThread == null) { return(HttpNotFound()); } if (UserContext.CurrentUser.UserId == blogThread.UserId) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "无效操作", Body = "不能转载自己的日志", StatusMessageType = StatusMessageType.Error }))); } BlogThreadEditModel model = new BlogThreadEditModel() { PrivacyStatus = PrivacyStatus.Public }; model.ThreadId = threadId; //日志用户分类下拉列表 IEnumerable <Category> ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread()); ViewData["ownerCategories"] = new SelectList(ownerCategories, "CategoryId", "CategoryName", null); return(View(model)); }
public ActionResult _Reproduce(string spaceKey, BlogThreadEditModel model) { IUser currentUser = UserContext.CurrentUser; BlogThread blogThread = blogService.Get(model.ThreadId); if (blogThread == null) { return HttpNotFound(); } BlogThread reproducedBlogThread = BlogThread.New(); reproducedBlogThread.IsDraft = false; reproducedBlogThread.IsReproduced = true; reproducedBlogThread.Keywords = blogThread.Keywords; reproducedBlogThread.Subject = blogThread.Subject; reproducedBlogThread.Body = blogThread.GetBody(); reproducedBlogThread.Summary = blogThread.Summary; reproducedBlogThread.UserId = currentUser.UserId; reproducedBlogThread.OwnerId = currentUser.UserId; reproducedBlogThread.TenantTypeId = TenantTypeIds.Instance().User(); reproducedBlogThread.Author = currentUser.DisplayName; reproducedBlogThread.OriginalAuthorId = blogThread.OriginalAuthorId; reproducedBlogThread.PrivacyStatus = model.PrivacyStatus; reproducedBlogThread.FeaturedImage = blogThread.FeaturedImage; reproducedBlogThread.FeaturedImageAttachmentId = blogThread.FeaturedImageAttachmentId; reproducedBlogThread.OriginalThreadId = blogThread.ThreadId; //替换附件 IEnumerable<Attachment> attachments = attachmentService.GetsByAssociateId(blogThread.ThreadId); if (attachments != null && attachments.Count() > 0) { foreach (var attachment in attachments) { Attachment newAttachment = null; //如果该附件有售价并且该用户没有购买过(下载过)该附件则不转载附件 if (attachment.Price > 0 && !attachmentDownloadService.IsDownloaded(currentUser.UserId, attachment.AttachmentId)) { string oldAttach = "[attach:" + attachment.AttachmentId + "]"; reproducedBlogThread.Body = reproducedBlogThread.Body.Replace(oldAttach, ""); } else { newAttachment = attachmentService.CloneForUser(attachment, currentUser.UserId); string oldAttach = "[attach:" + attachment.AttachmentId + "]"; string newAttach = "[attach:" + newAttachment.AttachmentId + "]"; reproducedBlogThread.Body = reproducedBlogThread.Body.Replace(oldAttach, newAttach); //替换标题图 if (blogThread.FeaturedImageAttachmentId > 0 && blogThread.FeaturedImageAttachmentId == attachment.AttachmentId) { reproducedBlogThread.FeaturedImage = newAttachment.GetRelativePath() + "\\" + newAttachment.FileName; reproducedBlogThread.FeaturedImageAttachmentId = newAttachment.AttachmentId; } } } } bool isCreated = blogService.Create(reproducedBlogThread, model.PrivacyStatus1, model.PrivacyStatus2); if (!isCreated) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "发布失败", Body = "发布失败,请稍后再试!", StatusMessageType = StatusMessageType.Hint })); } ////设置隐私状态 //UpdatePrivacySettings(reproducedBlogThread, model.PrivacyStatus1, model.PrivacyStatus2); //设置用户分类 if (!string.IsNullOrEmpty(model.OwnerCategoryIds)) { string[] ownerCategoryIds = model.OwnerCategoryIds.TrimEnd(',').Split(','); categoryService.AddCategoriesToItem(ownerCategoryIds.Select(n => long.Parse(n)), reproducedBlogThread.ThreadId); } //设置标签(如此处理是因为标签选择器会输出两个同名的hidden input) if (model.TagNames != null && model.TagNames.Count() == 2 && !string.IsNullOrEmpty(model.TagNames.ElementAt(1))) { tagService.AddTagsToItem(model.TagNames.ElementAt(1), reproducedBlogThread.UserId, reproducedBlogThread.ThreadId); } // return Redirect(SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId)); return Redirect(SiteUrls.Instance().BlogDetail(spaceKey, reproducedBlogThread.ThreadId)); }
public ActionResult _Reproduce(string spaceKey, long threadId) { BlogThread blogThread = blogService.Get(threadId); if (blogThread == null) { return HttpNotFound(); } if (UserContext.CurrentUser.UserId == blogThread.UserId) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "无效操作", Body = "不能转载自己的文章", StatusMessageType = StatusMessageType.Hint })); } BlogThreadEditModel model = new BlogThreadEditModel() { PrivacyStatus = PrivacyStatus.Public }; model.ThreadId = threadId; //文章用户分类下拉列表 IEnumerable<Category> ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread()); ViewData["ownerCategories"] = new SelectList(ownerCategories, "CategoryId", "CategoryName", null); return View(model); }
public ActionResult Edit(string spaceKey, BlogThreadEditModel model) { string errorMessage = string.Empty; if (ModelState.HasBannedWord(out errorMessage)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "发布失败", Body = errorMessage, StatusMessageType = StatusMessageType.Hint })); } BlogThread blogThread = model.AsBlogThread(); //写文章 if (model.ThreadId == 0) { if (!authorizer.BlogThread_Create(spaceKey, out errorMessage)) { if (model.IsDraft) { return Json(new StatusMessageData(StatusMessageType.Error, "没有权限创建新的文章!")); } else { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = errorMessage, StatusMessageType = StatusMessageType.Hint })); } } // blogThread = model.AsBlogThread(); bool isCreated = blogService.Create(blogThread,model.PrivacyStatus1, model.PrivacyStatus2); if (!isCreated) { if (model.IsDraft) { return Json(new StatusMessageData(StatusMessageType.Error, "发布失败,请稍后再试!")); } else { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "发布失败", Body = "发布失败,请稍后再试!", StatusMessageType = StatusMessageType.Hint })); } } } //编辑文章 else { // blogThread = model.AsBlogThread(); if (!authorizer.BlogThread_Edit(blogThread)) { if (model.IsDraft) { return Json(new StatusMessageData(StatusMessageType.Error, "没有权限编辑" + blogThread.Subject + "!")); } else { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = "没有权限编辑" + blogThread.Subject + "!", StatusMessageType = StatusMessageType.Hint })); } } //如果之前是草稿,现在正式发布,那么需要先删除草稿,然后创建新的文章 if (blogThread.IsDraft && !model.IsDraft) { blogThread.IsDraft = false; blogThread = blogThread.Clone(); blogService.Delete(blogThread.ThreadId); bool isCreated = blogService.Create(blogThread,model.PrivacyStatus1, model.PrivacyStatus2); } else { blogService.Update(blogThread,privacyStatus1:model.PrivacyStatus1,privacyStatus2: model.PrivacyStatus2); //清除用户分类 categoryService.ClearCategoriesFromItem(blogThread.ThreadId, blogThread.OwnerId, TenantTypeIds.Instance().BlogThread()); if (blogSettings.AllowSetSiteCategory) { //清除站点分类(投稿到) categoryService.ClearCategoriesFromItem(blogThread.ThreadId, 0, TenantTypeIds.Instance().BlogThread()); } //清除标签 tagService.ClearTagsFromItem(blogThread.ThreadId, blogThread.UserId); } } ////设置隐私状态 //UpdatePrivacySettings(blogThread, model.PrivacyStatus1, model.PrivacyStatus2); //设置用户分类 if (!string.IsNullOrEmpty(model.OwnerCategoryIds)) { string[] ownerCategoryIds = model.OwnerCategoryIds.TrimEnd(',').Split(','); categoryService.AddCategoriesToItem(ownerCategoryIds.Select(n => long.Parse(n)), blogThread.ThreadId); } if (blogSettings.AllowSetSiteCategory) { //设置站点分类(投稿到) if (model.SiteCategoryId.HasValue) { categoryService.AddCategoriesToItem(new List<long> { model.SiteCategoryId.Value }, blogThread.ThreadId); } } string tags = string.Join(",", model.TagNames); if (!string.IsNullOrEmpty(tags)) { tagService.AddTagsToItem(tags, blogThread.UserId, blogThread.ThreadId); } //如果是保存草稿,则返回Json if (blogThread.IsDraft) { return Json(new { MessageType = StatusMessageType.Success, MessageContent = "保存成功!", ThreadId = blogThread.ThreadId }); } else { return Redirect(SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId)); //return Json(new { MessageType = StatusMessageType.Success, MessageContent = SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId), ThreadId = blogThread.ThreadId }); } }
public ActionResult Edit(string spaceKey, long? threadId, long? ownerId) { BlogThreadEditModel model = null; BlogThread blogThread = null; //文章用户分类下拉列表 IEnumerable<Category> ownerCategories = null; //写文章 if (!threadId.HasValue) { string errorMessage = string.Empty; if (!authorizer.BlogThread_Create(spaceKey, out errorMessage)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = errorMessage, StatusMessageType = StatusMessageType.Hint })); } model = new BlogThreadEditModel() { PrivacyStatus = PrivacyStatus.Public }; if (ownerId.HasValue) { model.OwnerId = ownerId; } //获取所有者分类 if (ownerId.HasValue) { ownerCategories = categoryService.GetOwnerCategories(ownerId.Value, TenantTypeIds.Instance().BlogThread()); } else { ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread()); } pageResourceManager.InsertTitlePart("写文章"); } //编辑文章 else { blogThread = blogService.Get(threadId.Value); if (blogThread == null) { return HttpNotFound(); } if (!authorizer.BlogThread_Edit(blogThread)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = "没有权限编辑" + blogThread.Subject + "!", StatusMessageType = StatusMessageType.Hint })); } Dictionary<int, IEnumerable<ContentPrivacySpecifyObject>> privacySpecifyObjects = contentPrivacyService.GetPrivacySpecifyObjects(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId); if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().User())) { IEnumerable<ContentPrivacySpecifyObject> userPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().User()]; ViewData["userPrivacySpecifyObjects"] = string.Join(",", userPrivacySpecifyObjects.Select(n => n.SpecifyObjectId)); } if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().UserGroup())) { IEnumerable<ContentPrivacySpecifyObject> userGroupPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().UserGroup()]; ViewData["userGroupPrivacySpecifyObjects"] = string.Join(",", userGroupPrivacySpecifyObjects.Select(n => n.SpecifyObjectId)); } model = blogThread.AsEditModel(); //获取所有者分类 ownerCategories = categoryService.GetOwnerCategories(blogThread.OwnerId, TenantTypeIds.Instance().BlogThread()); IEnumerable<Category> selectedOwnerCategories = blogThread.OwnerCategories; Dictionary<long, Category> ownerCategoryDic = new Dictionary<long, Category>(); if (selectedOwnerCategories != null && selectedOwnerCategories.Count() > 0) { ownerCategoryDic = selectedOwnerCategories.ToDictionary(n => n.CategoryId, n => n); } ViewData["ownerCategoryDic"] = ownerCategoryDic; pageResourceManager.InsertTitlePart("编辑文章"); } ViewData["ownerCategories"] = ownerCategories; //文章站点分类下拉列表(投稿到) if (blogSettings.AllowSetSiteCategory) { IEnumerable<Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread()); ViewData["siteCategories"] = new SelectList(siteCategories, "CategoryId", "CategoryName", blogThread == null ? null : blogThread.SiteCategoryId); } return View(model); }
public ActionResult Edit(string spaceKey, long?threadId, long?ownerId) { BlogThreadEditModel model = null; BlogThread blogThread = null; //日志用户分类下拉列表 IEnumerable <Category> ownerCategories = null; //写日志 if (!threadId.HasValue) { string errorMessage = string.Empty; if (!authorizer.BlogThread_Create(spaceKey, out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = errorMessage, StatusMessageType = StatusMessageType.Error }))); } model = new BlogThreadEditModel() { PrivacyStatus = PrivacyStatus.Public }; if (ownerId.HasValue) { model.OwnerId = ownerId; } //获取所有者分类 if (ownerId.HasValue) { ownerCategories = categoryService.GetOwnerCategories(ownerId.Value, TenantTypeIds.Instance().BlogThread()); } else { ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread()); } pageResourceManager.InsertTitlePart("写日志"); } //编辑日志 else { blogThread = blogService.Get(threadId.Value); if (blogThread == null) { return(HttpNotFound()); } if (!authorizer.BlogThread_Edit(blogThread)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = "没有权限编辑" + blogThread.Subject + "!", StatusMessageType = StatusMessageType.Error }))); } Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > privacySpecifyObjects = contentPrivacyService.GetPrivacySpecifyObjects(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId); if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().User())) { IEnumerable <ContentPrivacySpecifyObject> userPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().User()]; ViewData["userPrivacySpecifyObjects"] = string.Join(",", userPrivacySpecifyObjects.Select(n => n.SpecifyObjectId)); } if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().UserGroup())) { IEnumerable <ContentPrivacySpecifyObject> userGroupPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().UserGroup()]; ViewData["userGroupPrivacySpecifyObjects"] = string.Join(",", userGroupPrivacySpecifyObjects.Select(n => n.SpecifyObjectId)); } model = blogThread.AsEditModel(); //获取所有者分类 ownerCategories = categoryService.GetOwnerCategories(blogThread.OwnerId, TenantTypeIds.Instance().BlogThread()); IEnumerable <Category> selectedOwnerCategories = blogThread.OwnerCategories; Dictionary <long, Category> ownerCategoryDic = new Dictionary <long, Category>(); if (selectedOwnerCategories != null && selectedOwnerCategories.Count() > 0) { ownerCategoryDic = selectedOwnerCategories.ToDictionary(n => n.CategoryId, n => n); } ViewData["ownerCategoryDic"] = ownerCategoryDic; pageResourceManager.InsertTitlePart("编辑日志"); } ViewData["ownerCategories"] = ownerCategories; //日志站点分类下拉列表(投稿到) if (blogSettings.AllowSetSiteCategory) { IEnumerable <Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread()); ViewData["siteCategories"] = new SelectList(siteCategories, "CategoryId", "CategoryName", blogThread == null ? null : blogThread.SiteCategoryId); } return(View(model)); }
public ActionResult _Reproduce(string spaceKey, BlogThreadEditModel model) { IUser currentUser = UserContext.CurrentUser; BlogThread blogThread = blogService.Get(model.ThreadId); if (blogThread == null) { return(HttpNotFound()); } BlogThread reproducedBlogThread = BlogThread.New(); reproducedBlogThread.IsDraft = false; reproducedBlogThread.IsReproduced = true; reproducedBlogThread.Keywords = blogThread.Keywords; reproducedBlogThread.Subject = blogThread.Subject; reproducedBlogThread.Body = blogThread.GetBody(); reproducedBlogThread.Summary = blogThread.Summary; reproducedBlogThread.UserId = currentUser.UserId; reproducedBlogThread.OwnerId = currentUser.UserId; reproducedBlogThread.TenantTypeId = TenantTypeIds.Instance().User(); reproducedBlogThread.Author = currentUser.DisplayName; reproducedBlogThread.OriginalAuthorId = blogThread.OriginalAuthorId; reproducedBlogThread.PrivacyStatus = model.PrivacyStatus; reproducedBlogThread.FeaturedImage = blogThread.FeaturedImage; reproducedBlogThread.FeaturedImageAttachmentId = blogThread.FeaturedImageAttachmentId; reproducedBlogThread.OriginalThreadId = blogThread.ThreadId; //替换附件 IEnumerable <Attachment> attachments = attachmentService.GetsByAssociateId(blogThread.ThreadId); if (attachments != null && attachments.Count() > 0) { foreach (var attachment in attachments) { Attachment newAttachment = null; //如果该附件有售价并且该用户没有购买过(下载过)该附件则不转载附件 if (attachment.Price > 0 && !attachmentDownloadService.IsDownloaded(currentUser.UserId, attachment.AttachmentId)) { string oldAttach = "[attach:" + attachment.AttachmentId + "]"; reproducedBlogThread.Body = reproducedBlogThread.Body.Replace(oldAttach, ""); } else { newAttachment = attachmentService.CloneForUser(attachment, currentUser.UserId); string oldAttach = "[attach:" + attachment.AttachmentId + "]"; string newAttach = "[attach:" + newAttachment.AttachmentId + "]"; reproducedBlogThread.Body = reproducedBlogThread.Body.Replace(oldAttach, newAttach); //替换标题图 if (blogThread.FeaturedImageAttachmentId > 0 && blogThread.FeaturedImageAttachmentId == attachment.AttachmentId) { reproducedBlogThread.FeaturedImage = newAttachment.GetRelativePath() + "\\" + newAttachment.FileName; reproducedBlogThread.FeaturedImageAttachmentId = newAttachment.AttachmentId; } } } } bool isCreated = blogService.Create(reproducedBlogThread); if (!isCreated) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "发布失败", Body = "发布失败,请稍后再试!", StatusMessageType = StatusMessageType.Error }))); } //设置隐私状态 UpdatePrivacySettings(reproducedBlogThread, model.PrivacyStatus1, model.PrivacyStatus2); //设置用户分类 if (!string.IsNullOrEmpty(model.OwnerCategoryIds)) { string[] ownerCategoryIds = model.OwnerCategoryIds.TrimEnd(',').Split(','); categoryService.AddCategoriesToItem(ownerCategoryIds.Select(n => long.Parse(n)), reproducedBlogThread.ThreadId, reproducedBlogThread.OwnerId); } //设置标签(如此处理是因为标签选择器会输出两个同名的hidden input) if (model.TagNames != null && model.TagNames.Count() == 2 && !string.IsNullOrEmpty(model.TagNames.ElementAt(1))) { tagService.AddTagsToItem(model.TagNames.ElementAt(1), reproducedBlogThread.UserId, reproducedBlogThread.ThreadId); } return(Redirect(SiteUrls.Instance().BlogDetail(currentUser.UserName, reproducedBlogThread.ThreadId))); }
public ActionResult Edit(string spaceKey, BlogThreadEditModel model) { string errorMessage = string.Empty; if (ModelState.HasBannedWord(out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "发布失败", Body = errorMessage, StatusMessageType = StatusMessageType.Error }))); } BlogThread blogThread = null; //写日志 if (model.ThreadId == 0) { if (!authorizer.BlogThread_Create(spaceKey, out errorMessage)) { if (model.IsDraft) { return(Json(new StatusMessageData(StatusMessageType.Error, "没有权限创建新的日志!"))); } else { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = errorMessage, StatusMessageType = StatusMessageType.Error }))); } } blogThread = model.AsBlogThread(); bool isCreated = blogService.Create(blogThread); if (!isCreated) { if (model.IsDraft) { return(Json(new StatusMessageData(StatusMessageType.Error, "发布失败,请稍后再试!"))); } else { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "发布失败", Body = "发布失败,请稍后再试!", StatusMessageType = StatusMessageType.Error }))); } } } //编辑日志 else { blogThread = model.AsBlogThread(); if (!authorizer.BlogThread_Edit(blogThread)) { if (model.IsDraft) { return(Json(new StatusMessageData(StatusMessageType.Error, "没有权限编辑" + blogThread.Subject + "!"))); } else { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = "没有权限编辑" + blogThread.Subject + "!", StatusMessageType = StatusMessageType.Error }))); } } //如果之前是草稿,现在正式发布,那么需要先删除草稿,然后创建新的日志 BlogThread oldBlogThread = blogService.Get(blogThread.ThreadId); if (oldBlogThread.IsDraft && !blogThread.IsDraft) { blogService.Delete(oldBlogThread); bool isCreated = blogService.Create(blogThread); } else { blogService.Update(blogThread); //清除用户分类 categoryService.ClearCategoriesFromItem(blogThread.ThreadId, blogThread.OwnerId, TenantTypeIds.Instance().BlogThread()); if (blogSettings.AllowSetSiteCategory) { //清除站点分类(投稿到) categoryService.ClearCategoriesFromItem(blogThread.ThreadId, 0, TenantTypeIds.Instance().BlogThread()); } //清除标签 tagService.ClearTagsFromItem(blogThread.ThreadId, blogThread.UserId); } } //设置隐私状态 UpdatePrivacySettings(blogThread, model.PrivacyStatus1, model.PrivacyStatus2); //设置用户分类 if (!string.IsNullOrEmpty(model.OwnerCategoryIds)) { string[] ownerCategoryIds = model.OwnerCategoryIds.TrimEnd(',').Split(','); categoryService.AddCategoriesToItem(ownerCategoryIds.Select(n => long.Parse(n)), blogThread.ThreadId, blogThread.OwnerId); } if (blogSettings.AllowSetSiteCategory) { //设置站点分类(投稿到) if (model.SiteCategoryId.HasValue) { categoryService.AddCategoriesToItem(new List <long> { model.SiteCategoryId.Value }, blogThread.ThreadId, 0); } } string tags = string.Join(",", model.TagNames); if (!string.IsNullOrEmpty(tags)) { tagService.AddTagsToItem(tags, blogThread.UserId, blogThread.ThreadId); } //如果是保存草稿,则返回Json if (blogThread.IsDraft) { return(Json(new { MessageType = StatusMessageType.Success, MessageContent = "保存成功!", ThreadId = blogThread.ThreadId })); } else { return(Redirect(SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId))); //return Json(new { MessageType = StatusMessageType.Success, MessageContent = SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId), ThreadId = blogThread.ThreadId }); } }