Ejemplo n.º 1
0
    protected void btSave_Click(object sender, EventArgs e)
    {
        try
        {
            string id = Request["id"];

            Category         category;
            IList <Category> categories = GetAllViewableCategories();

            //Edit
            if (id != null)
            {
                category             = DocoManager.GetCategory(id);
                category.DisplayName = txtDisplayName.Text;
            }
            else //New
            {
                category = DocoManager.CreateCategory(txtDisplayName.Text);
            }

            Category parentCategory = categories[cmbParentCategory.SelectedIndex];
            // The parent category can be assiged as the same category, do not allow this.
            // Also do not allow the root category (with parent null) to be changed.
            if (!parentCategory.Id.Equals(category.Id) && category.ParentCategory != null)
            {
                category.ParentCategory = categories[cmbParentCategory.SelectedIndex];
            }
            category.Description = txtDescription.Text;
            DocoManager.UpdateCategory(category);
            IList <Access> currentAccess = AccessManager.GetItemAccess(category.Id);

            foreach (Access access in currentAccess)
            {
                AccessManager.RemoveAccess(access.Id);
            }

            foreach (Access a in AccessControl1.AccessList)
            {
                a.Id       = null;
                a.ItemId   = category.Id;
                a.ItemType = ItemType.DocoCategory;
                AccessManager.AddAccess(a);
            }

            ((IFeedback)this.Page.Master).QueueFeedback(
                BusiBlocksConstants.Blocks.Documents.LongName,
                "Category",
                Feedback.Actions.Saved,
                category.DisplayName
                );

            Navigation.Admin_ManageDoco().Redirect(this);
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Master).SetException(GetType(), ex);
        }
    }
Ejemplo n.º 2
0
    protected void AddCategoryClick(object sender, EventArgs e)
    {
        string categoryName     = popAddCategory.Value;
        string categoryId       = popAddCategory.ReferrerId;
        string categoryTypeName = string.Empty;

        // 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);
                categoryTypeName = news.GetType().Name;
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                BusiBlocks.CommsBlock.News.Category childCategory = NewsManager.CreateCategory(categoryName);
                childCategory.ParentCategory = news;
                NewsManager.UpdateCategory(childCategory);
                this.PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetAllCategories(), true, false, string.Empty);
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;
                try
                {
                    doco             = DocoManager.GetCategory(categoryId);
                    categoryTypeName = doco.GetType().Name;
                }
                catch (DocoCategoryNotFoundException) { }
                if (doco != null)
                {
                    BusiBlocks.DocoBlock.Category childDocoCategory = DocoManager.CreateCategory(categoryName);
                    childDocoCategory.ParentCategory = doco;
                    DocoManager.UpdateCategory(childDocoCategory);
                    this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
                }
            }
            RadTreeView1.DataBind();
            RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(categoryName).Selected = true;

            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Created,
                categoryName
                );
        }
    }
Ejemplo n.º 3
0
    public void EditCategory(string Id, string Name, string treeViewName)
    {
        switch (treeViewName)
        {
        case "News":
            BusiBlocks.CommsBlock.News.Category category = NewsManager.GetCategory(Id);
            category.Name = Name;
            NewsManager.UpdateCategory(category);
            break;

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

        default:
            break;
        }
    }
Ejemplo n.º 4
0
    public void MoveCategory(string source, string destination, string treeViewName)
    {
        switch (treeViewName)
        {
        case "News":
            BusiBlocks.CommsBlock.News.Category destNewsCategory   = NewsManager.GetCategoryByName(destination, true);
            BusiBlocks.CommsBlock.News.Category sourceNewsCategory = NewsManager.GetCategoryByName(source, true);
            sourceNewsCategory.ParentCategory = destNewsCategory;
            NewsManager.UpdateCategory(sourceNewsCategory);
            break;

        case "Doco":
            BusiBlocks.DocoBlock.Category destDocoCategory   = DocoManager.GetCategoryByName(destination, true);
            BusiBlocks.DocoBlock.Category sourceDocoCategory = DocoManager.GetCategoryByName(source, true);
            sourceDocoCategory.ParentCategory = destDocoCategory;
            DocoManager.UpdateCategory(sourceDocoCategory);
            break;

        default:
            break;
        }
    }