//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using CommunityServer.Components;

namespace CommunityServer.ControlPanel.Blogs
{
    public class DeleteCategoryCommand : BlogCommand
    {
        public override string Message(BlogCommandPage page)
        {
            PostCategory pc = GetCategory(page);

            return "Are you sure you want to the category <strong>" + pc.Name + "</strong>? This action can not be undone.";
        }

        public override void Action(BlogCommandPage page)
        {
            PostCategory pc = GetCategory(page);
            PostCategories.DeleteCategory(pc.CategoryID,pc.SectionID);
        }

        protected PostCategory GetCategory(BlogCommandPage page)
        {
            PostCategory pc = PostCategories.GetCategory(Int32.Parse(page.Request.QueryString["CategoryID"]),page.CurrentWeblog.SectionID);
            if(pc.SectionID != page.CurrentWeblog.SectionID)
                throw new CSException(CSExceptionType.SectionNotFound);

            return pc;
        }

        public override string Title
        {
            get { return "Delete Category";}
        }

//		public override string CloseScript(BlogCommandPage page)
//		{
//			return "alert('I am overriden'); " + base.CloseScript (page);
//		}

    }
}