using PageAdmin.BLL;
using PageAdmin.Utils;
using System.Web.Mvc;

namespace PageAdmin.Web.Areas.Admin.Controllers
{
    public class RoleController: DefaultBaseController
    {
        public RoleController():base("pa_role", "User")
        {
            base.DeleteExecuting =OnDeleteExecuting;
            base.DeleteExecuted = DeleteRelative;
            base.MvcContext.ListOrder = "id asc";
        }


        /// <summary>
        /// 只能删除非超级管理员组
        /// </summary>
        private void OnDeleteExecuting()
        {
            base.MvcContext.SqlCondition="isSuperadmin=0";
        }


        //同步删除相关方法
        private void DeleteRelative()
        {
            int roleId = StringHelper.Format<int>(Request.Form["id"]);
            RoleBLL roleBll = new RoleBLL();
            roleBll.DeleteRelative(roleId);
        }

        [HttpGet]
        [NotCheckMenuItemPermissions]
        public ActionResult Select()
        {
            return View();
        }
    }
}