public AjaxResponse CreateCategory(string name, string description) { var resp = new AjaxResponse(); if (!ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { resp.rs1 = "0"; resp.rs2 = "<div class='errorBox'>" + Resources.ForumResource.ErrorAccessDenied + "</div>"; return(resp); } if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(name.Trim())) { resp.rs1 = "0"; resp.rs2 = "<div class='errorBox'>" + Resources.ForumResource.ErrorEmptyName + "</div>"; return(resp); } var category = new ThreadCategory() { Title = name.Trim(), Description = description ?? "", SortOrder = 100 }; try { category.ID = ForumDataProvider.CreateThreadCategory(TenantProvider.CurrentTenantID, category.Title, category.Description, category.SortOrder); resp.rs1 = "1"; resp.rs2 = RenderForumCategory(category, new List <Thread>()); } catch { resp.rs1 = "0"; resp.rs2 = "<div>" + Resources.ForumResource.ErrorCreateThreadCategory + "</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); }