コード例 #1
0
        public IActionResult GetAllRole()
        {
            Tright_Role_Da rolemanger = new Tright_Role_Da();
            var            list       = rolemanger.Select.OrderBy(s => s.Id).ToList();

            return(SuccessResultList(list));
        }
コード例 #2
0
        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("添加成功!"));
        }
コード例 #3
0
        public IActionResult DelRole(int id)
        {
            Tright_Role_Da da = new Tright_Role_Da();

            if (da.Delete(s => s.Id == id) > 0)
            {
                return(SuccessMessage("已删除!"));
            }
            return(FailMessage());
        }
コード例 #4
0
        public IActionResult UpdateRole(Tright_Role model)
        {
            if (string.IsNullOrEmpty(model.Role_Name))
            {
                return(FailMessage("角色名不能为空!"));
            }

            Tright_Role_Da da = new Tright_Role_Da();

            da.Update(model);
            return(SuccessMessage("成功!"));
        }
コード例 #5
0
        public IActionResult AddRole(Tright_Role model)
        {
            if (string.IsNullOrEmpty(model.Rolename))
            {
                return(FailMessage("角色名不能为空!"));
            }


            Tright_Role_Da da = new Tright_Role_Da();

            da.Insert(model);
            return(SuccessMessage("添加成功!"));
        }
コード例 #6
0
        public IActionResult DelRole(int id)
        {
            Tright_Role_Da da = new Tright_Role_Da();

            Tright_Role_Power_Da rpda = new Tright_Role_Power_Da();
            var rp = rpda.Select.Where(s => s.Role_Id == id).ToOne();


            Tright_Power_Da powerda = new Tright_Power_Da();

            if (da.Delete(s => s.Id == id) > 0 && powerda.Delete(s => s.Id == rp.Power_Id) > 0)
            {
                return(SuccessMessage("已删除!"));
            }

            return(FailMessage());
        }
コード例 #7
0
        public IActionResult ListRole()
        {
            Tright_Role_Da da = new Tright_Role_Da();

            return(SuccessResultList(da.Select.ToList()));
        }