public string UpdateCategorySortOrder(string sortOrders)
        {
            try
            {
                if (!ForumManager.Instance.ValidateAccessSecurityAction(ASC.Forum.ForumAction.GetAccessForumEditor, null))
                {
                    throw new Exception(Resources.ForumResource.ErrorAccessDenied);
                }

                List <ThreadCategory> categories;
                List <Thread>         threads;
                ForumDataProvider.GetThreadCategories(TenantProvider.CurrentTenantID, out categories, out threads);

                foreach (var so in sortOrders.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var cid      = Convert.ToInt32(so.Split(':')[0]);
                    var order    = Convert.ToInt32(so.Split(':')[1]);
                    var category = categories.Find(c => c.ID == cid);

                    if (category != null)
                    {
                        category.SortOrder = order;
                        ForumDataProvider.UpdateThreadCategory(TenantProvider.CurrentTenantID, category.ID,
                                                               category.Title, category.Description, category.SortOrder);
                    }
                }

                return("ok");
            }
            catch (Exception e)
            {
                return(e.Message.HtmlEncode());
            }
        }
        public AjaxResponse SaveCategory(int id, string name, string description)
        {
            var resp = new AjaxResponse
            {
                rs2 = id.ToString()
            };

            List <Thread> threads;
            var           category = ForumDataProvider.GetCategoryByID(TenantProvider.CurrentTenantID, id, 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);
            }


            category.Title       = name.Trim();
            category.Description = description ?? "";

            try
            {
                ForumDataProvider.UpdateThreadCategory(TenantProvider.CurrentTenantID, category.ID, category.Title, category.Description, category.SortOrder);
                resp.rs1 = "1";
                resp.rs3 = RenderForumCategory(category, threads);
            }
            catch
            {
                resp.rs1 = "0";
                resp.rs3 = "<div>" + Resources.ForumResource.ErrorEditThreadCategory + "</div>";
            }
            return(resp);
        }