public AjaxResponse DoCreateThread(int categoryId, string name, string description) { AjaxResponse resp = new AjaxResponse(); resp.rs2 = categoryId.ToString(); var threads = new List <Thread>(); var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, categoryId, out threads); if (category == null || !ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { resp.rs1 = "0"; resp.rs3 = "<div>" + Resources.ForumResource.ErrorAccessDenied + "</div>"; return(resp); } if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(name.Trim())) { resp.rs1 = "0"; resp.rs3 = "<div>" + Resources.ForumResource.ErrorEmptyName + "</div>"; return(resp); } var thread = new Thread() { Title = name.Trim(), Description = description ?? "", SortOrder = 100, CategoryID = category.ID }; try { thread.ID = ForumDataProvider.CreateThread(TenantProvider.CurrentTenantID, thread.CategoryID, thread.Title, thread.Description, thread.SortOrder); threads.Add(thread); resp.rs1 = "1"; resp.rs3 = RenderForumCategory(category, threads); ForumActivityPublisher.NewThread(thread); } catch { resp.rs1 = "0"; resp.rs3 = "<div>" + Resources.ForumResource.ErrorEditThreadCategory + "</div>"; } return(resp); }
public ForumThreadWrapper AddThreadToCategory(int categoryId, string categoryName, string threadName, string threadDescription) { categoryName = categoryName.Trim(); threadName = threadName.Trim(); threadDescription = threadDescription.Trim(); if (!ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { throw new Exception("Error access denied"); } if (String.IsNullOrEmpty(threadName)) { throw new Exception("Error empty thread name"); } var thread = new Thread { Title = threadName, Description = threadDescription, SortOrder = 100, CategoryID = categoryId }; if (thread.CategoryID == -1) { if (String.IsNullOrEmpty(categoryName)) { throw new Exception("Error empty category name"); } thread.CategoryID = ForumDataProvider.CreateThreadCategory(TenantId, categoryName, String.Empty, 100); } var threadId = ForumDataProvider.CreateThread(TenantId, thread.CategoryID, thread.Title, thread.Description, thread.SortOrder); thread = ForumDataProvider.GetThreadByID(TenantId, threadId); return(new ForumThreadWrapper(thread)); }
public AjaxResponse SaveThreadCategory(int categoryID, string categoryName, string threadName, string threadDescription, bool isRenderCategory) { AjaxResponse resp = new AjaxResponse(); if (!ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorAccessDenied + "</div>"; return(resp); } if (String.IsNullOrEmpty(threadName) || String.IsNullOrEmpty(threadName.Trim())) { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorThreadEmptyName + "</div>"; return(resp); } try { var thread = new Thread() { Title = threadName.Trim(), Description = threadDescription ?? "", SortOrder = 100, CategoryID = categoryID }; if (thread.CategoryID == -1) { if (String.IsNullOrEmpty(categoryName) || String.IsNullOrEmpty(categoryName.Trim())) { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorCategoryEmptyName + "</div>"; return(resp); } thread.CategoryID = ForumDataProvider.CreateThreadCategory(TenantProvider.CurrentTenantID, categoryName.Trim(), "", 100); } thread.ID = ForumDataProvider.CreateThread(TenantProvider.CurrentTenantID, thread.CategoryID, thread.Title, thread.Description, thread.SortOrder); resp.rs1 = "1"; resp.rs2 = thread.CategoryID.ToString(); if (isRenderCategory) { var threads = new List <Thread>(); var category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, thread.CategoryID, out threads); resp.rs3 = ForumEditor.RenderForumCategory(category, threads); } resp.rs4 = (categoryID == -1) ? "0" : "1"; ForumActivityPublisher.NewThread(thread); } catch (Exception ex) { resp.rs1 = "0"; resp.rs2 = "<div>" + ex.Message.HtmlEncode() + "</div>"; } return(resp); }