public ActionResult Edit(BarThreadEditModel barThreadEditModel) { SystemMessageViewModel message = new SystemMessageViewModel { Title = "发帖失败了!", Body = "发帖失败,请稍后再试!", StatusMessageType = StatusMessageType.Hint }; string errorMessage = string.Empty; if (ModelState.HasBannedWord(out errorMessage)) { message.Body = errorMessage; return Redirect(SiteUrls.Instance().SystemMessage(TempData, message, Request.RawUrl)); } if (barThreadEditModel.ThreadId > 0) { if (authorizer.BarThread_Edit(barThreadEditModel.AsBarThread())) { BarThread thread = barThreadEditModel.AsBarThread(); //编辑方法 barThreadService.Update(thread, UserContext.CurrentUser.UserId); long groupId = Request.Form.Get<long>("BarThreadCategory", 0); categoryService.ClearCategoriesFromItem(barThreadEditModel.ThreadId, barThreadEditModel.SectionId, TenantTypeIds.Instance().BarThread()); if (groupId > 0) categoryService.AddCategoriesToItem(new List<long> { groupId }, barThreadEditModel.ThreadId); tagService.ClearTagsFromItem(barThreadEditModel.ThreadId, barThreadEditModel.SectionId); string tags = string.Join(",", barThreadEditModel.TagNames); tagService.AddTagsToItem(tags, barThreadEditModel.SectionId, barThreadEditModel.ThreadId); IBarUrlGetter getter = BarUrlGetterFactory.Get(thread.TenantTypeId); return Redirect(getter.ThreadDetail(thread.ThreadId)); } else { message.Title = "编辑帖子失败!"; message.Body = "您没有权限编辑帖子!"; } } else { if (authorizer.BarThread_Create(barThreadEditModel.SectionId, out errorMessage)) { //新建方法 BarThread barThread = barThreadEditModel.AsBarThread(); bool isCreated = barThreadService.Create(barThread); if (isCreated) { long groupId = Request.Form.Get<long>("BarThreadCategory", 0); if (groupId > 0) categoryService.AddCategoriesToItem(new List<long> { groupId }, barThread.ThreadId); string tags = string.Join(",", barThreadEditModel.TagNames); tagService.AddTagsToItem(tags, barThread.SectionId, barThread.ThreadId); IBarUrlGetter getter = BarUrlGetterFactory.Get(barThread.TenantTypeId); return Redirect(getter.ThreadDetail(barThread.ThreadId)); } } else { message.Body = errorMessage; } } return Redirect(SiteUrls.Instance().SystemMessage(TempData, message, Request.RawUrl)); }
/// <summary> /// 编辑贴吧的局部视图 /// </summary> /// <param name="model"></param> /// <returns>编辑贴吧的局部视图</returns> public ActionResult _Edit(BarThreadEditModel model) { return View(model); }