Example #1
0
        public ActionResult Delete(int id)
        {
            RolePowerBll rp = new RolePowerBll();

            Utility.ReturnData <string> returnData = new Utility.ReturnData <string>();

            long check = bll.GetCountByRoleId(id);

            if (check > 0)
            {
                return(Content("角色存在关联,不能删除!"));
            }
            UserRole model = bll.FindUserRoleByID(id);

            returnData = bll.DeleteUserRole(model);
            rp.Delete(x => x.UserRoleID == id);
            if (returnData.Message == "删除成功!")
            {
                return(Content(returnData.Message));
            }
            else
            {
                return(Content(returnData.Message));
            }
        }
Example #2
0
        public ActionResult Edit(string[] CheckThis, string roleName1, int Mid)

        {
            string reg = "^[a-zA-Z0-9\u4e00-\u9fa5]+$";

            if (!Regex.IsMatch(roleName1.Trim(), reg))
            {
                return(Content("名称不允许有特殊字符!"));
            }
            if (roleName1.Trim() == "")
            {
                return(Content("名称不能为空!"));
            }
            if (roleName1.Trim().Length > 16)
            {
                return(Content("名称不能大于16位!"));
            }

            ReturnData <string> returnData = new ReturnData <string>();
            ReturnData <string> rd         = new ReturnData <string>();
            UserRole            roleModel  = bll.FindUserRoleByID(Mid);

            roleModel.RoleName = roleName1;
            returnData         = bll.AddOrUpdateUserRole(roleModel);

            IList <RolePower> list    = rpBll.getList(Mid);
            RolePower         rpModel = new RolePower();

            if (CheckThis == null)
            {
                rpBll.Delete(Mid);
                return(Content("添加成功!"));
            }
            if (list.Count != 0)
            {
                returnData = rpBll.Delete(Mid);
                if (returnData.Status == true)
                {
                    for (int i = 0; i < CheckThis.Length; i++)
                    {
                        rpModel.PowerID    = CheckThis[i];
                        rpModel.UserRoleID = Mid;
                        rd = rpBll.Add(rpModel);
                    }
                }
            }
            else
            {
                for (int i = 0; i < CheckThis.Length; i++)
                {
                    rpModel.PowerID    = CheckThis[i];
                    rpModel.UserRoleID = Mid;
                    rd = rpBll.Add(rpModel);
                }
            }
            if (rd.Status == true)
            {
                return(Content(rd.Message));
            }

            return(Content(rd.Message));
        }
Example #3
0
 public ActionResult Delete(int id)
 {
     RolePowerBll rp=new RolePowerBll();
     Utility.ReturnData<string> returnData = new Utility.ReturnData<string>();
    
     long check = bll.GetCountByRoleId(id);
     if (check > 0)
     {
         return Content("角色存在关联,不能删除!");
     }
     UserRole model = bll.FindUserRoleByID(id);
      returnData = bll.DeleteUserRole(model);
    rp.Delete(x=>x.UserRoleID==id);
     if (returnData.Message=="删除成功!")
     {
         return Content(returnData.Message);
     }
     else
     {
         return Content(returnData.Message);
     }
     
 }