Exemple #1
0
        public async Task DeleteRoleAsync(NullableIdDto <long> input)
        {
            if (!input.Id.HasValue)
            {
                throw new UserFriendlyException("Key不能为空!");
            }

            var entity = await _roleManage.GetRoleByIdAsync(input.Id.Value);

            entity.IsValid = !entity.IsValid;

            await _roleManage.UpdateRoleAsync(entity);

            await _roleManage.Delete(input.Id.Value);
        }
Exemple #2
0
        public ActionResult Delete(string idList)
        {
            var json = new JsonHelper()
            {
                Msg = "删除角色完毕", Status = "n"
            };
            var id = idList.Trim(',').Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToList();

            if (id.Contains(Common.Enums.ClsDic.DicRole["超级管理员"]))
            {
                json.Msg = "删除失败,不能删除系统固有角色!";
                WriteLog(Common.Enums.enumOperator.Remove, "删除用户角色:" + json.Msg, Common.Enums.enumLog4net.ERROR);
                return(Json(json));
            }
            if (this.UserRoleManage.IsExist(p => id.Contains(p.FK_ROLEID)))
            {
                json.Msg = "删除失败,不能删除系统中正在使用的角色!";
                WriteLog(Common.Enums.enumOperator.Remove, "删除用户角色:" + json.Msg, Common.Enums.enumLog4net.ERROR);
                return(Json(json));
            }
            try
            {
                //1、删除角色权限
                RolePermissionManage.Delete(p => id.Contains(p.ROLEID));
                //2、删除角色
                RoleManage.Delete(p => id.Contains(p.ID));
                json.Status = "y";
                WriteLog(Common.Enums.enumOperator.Remove, "删除用户角色:" + json.Msg, Common.Enums.enumLog4net.WARN);
            }
            catch (Exception e)
            {
                json.Msg = "删除用户角色发生内部错误!";
                WriteLog(Common.Enums.enumOperator.Remove, "删除用户角色:", e);
            }
            return(Json(json));
        }