Ejemplo n.º 1
0
    public void DeleteCategory(string Id)
    {
        // Need to figure out if this is a comms block category or a doco block category.
        if (!string.IsNullOrEmpty(Id))
        {
            BusiBlocks.CommsBlock.News.Category news = null;

            try
            {
                news = NewsManager.GetCategory(Id);
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                NewsManager.DeleteCategory(news);
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;

                try
                {
                    doco = DocoManager.GetCategory(Id);
                }
                catch (DocoCategoryNotFoundException) { }
                if (doco != null)
                {
                    DocoManager.DeleteCategory(doco);
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void DeleteCategory(string Id, string treeViewName)
    {
        switch (treeViewName)
        {
        case "News":
            BusiBlocks.CommsBlock.News.Category newsCategory = NewsManager.GetCategory(Id);
            NewsManager.DeleteCategory(newsCategory);
            break;

        case "Doco":
            BusiBlocks.DocoBlock.Category docoCategory = DocoManager.GetCategory(Id);
            DocoManager.DeleteCategory(docoCategory);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 3
0
    protected void DeleteCategoryClick(object sender, EventArgs e)
    {
        string categoryName       = string.Empty;
        string categoryId         = popDeleteCategory.ReferrerId;
        string categoryTypeName   = string.Empty;
        string parentCategoryName = string.Empty;
        bool   deleteFailure      = false;

        // Need to figure out if this is a comms block category or a doco block category.
        if (!string.IsNullOrEmpty(categoryId))
        {
            BusiBlocks.CommsBlock.News.Category news = null;
            try
            {
                news = NewsManager.GetCategory(categoryId);
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                categoryTypeName = news.GetType().Name;
                categoryName     = news.Name;

                // Don't allow the root category to be deleted.
                if (news.ParentCategory == null)
                {
                    ((IFeedback)this.Page.Master).ShowFeedback(
                        BusiBlocksConstants.Blocks.Administration.LongName,
                        news.Name,
                        Feedback.Actions.Error,
                        "Cannot delete the highest level category"
                        );
                    return;
                }

                parentCategoryName = news.ParentCategory.Name;
                IList <BusiBlocks.CommsBlock.News.Item>     newsItems         = NewsManager.GetItems(news, true);
                IList <BusiBlocks.CommsBlock.News.Category> newsSubCategories = NewsManager.GetCategories(news.Id, true);
                // NewsManager.GetCategories returns the root category, so it will always have at least one item
                if (newsSubCategories.Count <= 1 && newsItems.Count == 0)
                {
                    NewsManager.DeleteCategory(news);
                    PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetViewableCategories(Page.User.Identity.Name), true, false, string.Empty);
                }
                else
                {
                    deleteFailure = true;
                }
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;
                try
                {
                    doco = DocoManager.GetCategory(categoryId);
                }
                catch (DocoCategoryNotFoundException) { }

                if (doco != null)
                {
                    categoryTypeName   = doco.GetType().Name;
                    categoryName       = doco.DisplayName;
                    parentCategoryName = doco.ParentCategory.DisplayName;

                    IList <Article> docoItems = DocoManager.GetArticles(doco, ArticleStatus.All, true);
                    IList <BusiBlocks.DocoBlock.Category> docoSubCategories = DocoManager.GetAllCategoriesBelow(doco.Id);
                    if (docoSubCategories.Count == 0 && docoItems.Count == 0)
                    {
                        DocoManager.DeleteCategory(doco);
                        this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
                    }
                    else
                    {
                        deleteFailure = true;
                    }
                }
            }
            RadTreeView1.DataBind();
        }
        //Displaying feedback.
        if (deleteFailure)
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Error,
                ErrorCategoryNotEmpty
                );
            RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(categoryName).Selected = true;
        }
        else
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Deleted,
                categoryName
                );
            RadTreeView1.FindNodeByText(parentCategoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(parentCategoryName).Selected = true;
        }
    }