public ActionResult RoleDelete(int roleId) { if (roleId < 0) { return Content("无效操作"); } ActionResult ar; User currentUser; if (!UserVal(out ar, out currentUser)) { return ar; } var flag = currentUser.HasRoleManage(); if (!flag) { return Content("删除失败,权限不足"); } var delete = new UserRole { RoleId = roleId }.Remove(); if (delete) { return Content("删除成功"); } else { return Content("删除失败"); } }
public ActionResult RoleEdit(UserRole userRole) { ActionResult ar; User user; if (!UserVal(out ar,out user)) { return ar; } var manaFlag = user.HasRoleManage(); if (!manaFlag) { return Content("修改失败,权限不足"); } var flag = userRole.Update(userRole.RoleId, "RoleId"); var str = flag ? "修改成功" : "修改失败"; return Content(str); }
public ActionResult RoleAdd(UserRole userRole) { ActionResult ar; User user; if (!UserVal(out ar,out user)) { return ar; } var permFlag = user.HasPermManage(); if (!permFlag) { return Content("添加失败,权限不足"); } userRole.DesktopRole = 0; userRole.SystemRole = 0; var exist = userRole.ExistName(); if (exist) { return Content("添加失败,该名称已存在"); } var flag = userRole.Add(); if (flag) { return Content("添加成功"); } else { return Content("添加失败"); } }