public void DeleteCategory()
        {
            base.ThrowIfCannotActAsOwner();
            string             categoryName       = (string)base.GetParameter("nm");
            MasterCategoryList masterCategoryList = base.UserContext.GetMasterCategoryList(true);

            if (!masterCategoryList.Contains(categoryName))
            {
                return;
            }
            masterCategoryList.Remove(categoryName);
            masterCategoryList.Save();
        }
        public void CreateCategory()
        {
            base.ThrowIfCannotActAsOwner();
            string text = (string)base.GetParameter("nm");

            if (text.Length > 255)
            {
                throw new OwaInvalidRequestException("Category name cannot be longer than 255 characters.");
            }
            int color = (int)base.GetParameter("clr");

            if (!CategorySwatch.IsValidCategoryColor(color))
            {
                throw new OwaInvalidRequestException("Category color must be in the range [-1, 24].");
            }
            text = text.Trim();
            if (text.Length == 0)
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, 1243373352);
                return;
            }
            if (text.Contains(",") || text.Contains(";") || text.Contains("؛") || text.Contains("﹔") || text.Contains(";"))
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, 1243373352);
                return;
            }
            if (CategoryEventHandler.guidRegEx.IsMatch(text))
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, 1243373352);
                return;
            }
            MasterCategoryList masterCategoryList = base.UserContext.GetMasterCategoryList(true);

            if (masterCategoryList.Contains(text))
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, -210070156);
                return;
            }
            Category category = Category.Create(text, color, false);

            masterCategoryList.Add(category);
            ManageCategoriesDialog.RenderCategory(this.Writer, category);
            masterCategoryList.Save();
        }
        public void ChangeCategoryColor()
        {
            base.ThrowIfCannotActAsOwner();
            string text = (string)base.GetParameter("nm");

            if (string.IsNullOrEmpty(text))
            {
                throw new OwaInvalidRequestException("Category name cannot be null or empty.");
            }
            int color = (int)base.GetParameter("clr");

            if (!CategorySwatch.IsValidCategoryColor(color))
            {
                throw new OwaInvalidRequestException("Category color must be in the range [-1, 24].");
            }
            MasterCategoryList masterCategoryList = base.UserContext.GetMasterCategoryList(true);

            if (!masterCategoryList.Contains(text))
            {
                throw new OwaInvalidRequestException("Category does not exist");
            }
            masterCategoryList[text].Color = color;
            masterCategoryList.Save();
        }