public IActionResult AddRole(Tright_Role model)
        {
            if (string.IsNullOrEmpty(model.Role_Name))
            {
                return(FailMessage("角色名不能为空!"));
            }


            Tright_Role_Da da   = new Tright_Role_Da();
            var            role = da.Insert(model);


            Tright_Power_Da powerda = new Tright_Power_Da();

            Tright_Power powermodel = new Tright_Power();

            powermodel.Power_Type = model.Role_Name + "权限";

            var power = powerda.Insert(powermodel);


            Tright_Role_Power_Da rolepowerda    = new Tright_Role_Power_Da();
            Tright_Role_Power    rolepowermodel = new Tright_Role_Power();

            rolepowermodel.Role_Id  = role.Id;
            rolepowermodel.Power_Id = power.Id;

            rolepowerda.Insert(rolepowermodel);

            return(SuccessMessage("添加成功!"));
        }
        public IActionResult UpdateFunc(Tright_Power model)
        {
            // if (string.IsNullOrEmpty(model.Powername))
            // {
            //     return FailMessage("权限名不能为空!");
            // }

            //Tright_Power_Da da = new Tright_Power_Da();
            //da.Update(model);

            return(SuccessMessage("成功!"));
        }
Пример #3
0
        public IActionResult AddFunc(Tright_Power model)
        {
            if (string.IsNullOrEmpty(model.Powername))
            {
                return(FailMessage("权限名不能为空!"));
            }

            Tright_Power_Da da = new Tright_Power_Da();

            da.Insert(model);

            return(SuccessMessage("成功!"));
        }
Пример #4
0
        /// <summary>
        /// 根据Action自动添加功能
        /// </summary>
        /// <returns></returns>
        public void AddActionFunc(string controllerName, string actionName, string areaName, string page, bool isAjax)
        {
            //数据库是否存在该页面配置
            Tright_Power_Da pwmanager = new Tright_Power_Da();
            bool            HasPage   = pwmanager.Where(s => s.Pageurl.ToLower() == page.ToLower()).Count() <= 0;


            if (HasPage)
            {
                Tright_Power powermodel = new Tright_Power
                {
                    Controller = controllerName,
                    Action     = actionName,
                    Area       = areaName,
                    Powername  = PowerName,
                    Pageurl    = page.ToLower()
                };

                if (isAjax)
                {
                    // 添加一个功能功能操作的权限
                    var m = pwmanager.Where(s => s.Controller == controllerName && s.Powertype == (int)PowerType.页面访问).First();

                    powermodel.Parentid  = m.Id;
                    powermodel.Powertype = (int)PowerType.功能操作;
                }
                else
                {
                    //添加一个 页面访问 权限
                    powermodel.Parentid  = 0;
                    powermodel.Powertype = (int)PowerType.页面访问;
                }

                pwmanager.Insert(powermodel);
            }
        }