public IActionResult RoleRelateMenu() { try { var menus = _systemMenuService.GetAll(); var role = _systemRoleService.GetAll().FirstOrDefault(); RoleMenu roleMenu = null; foreach (var item in menus) { roleMenu = new RoleMenu() { Id = Guid.NewGuid().ToString(), AddTime = DateTime.Now, IsDelete = false, SystemMenus = item, SystemRoles = role }; _roleMenuService.Add(roleMenu); } _unitOfWork.Commit(); return(Ok()); } catch (Exception ex) { throw ex; } }
public ResponseResult <bool> Add(SysRoleMenu model) { _roleMenuService = GetService <RoleMenuService>(); var vIsSuess = _roleMenuService.Add(model) > 0; return(ResponseResult <bool> .GenSuccessResponse(vIsSuess)); }
public async Task <IActionResult> SetRoleMenu(RoleMenu_R roleMenu) { // var tmpData = _EFCoreService.GetRoleMenuByRoleId(roleMenu.RoleId); var tmpData = await _roleMenuService.GetRoleMenusByRoleId(roleMenu.RoleId); if (tmpData != null) { tmpData.SetTime = DateTime.Now; tmpData.MenuInfoId = roleMenu.MenuInfoId; var res = await _roleMenuService.Update(tmpData); return(new JsonResult(new Result { Data = res, Msg = $"设置{(res ? "成功" : "失败")}", Status = res ? 200 : 204 })); } else { roleMenu.RoleMenuId = Guid.NewGuid().ToString(); roleMenu.SetTime = DateTime.Now; //var res = _EFCoreService.SetRoleMenu(roleMenu); var res = await _roleMenuService.Add(roleMenu); return(new JsonResult(new Result { Data = res, Msg = $"设置{(res ? "成功" : "失败")}", Status = res ? 200 : 204 })); } }
public ResponseResult <bool> SaveRoleMenuPermissions(RoleMenuPermissionViewModel roleMenuPermissionVm) { var roleMenuList = roleMenuPermissionVm.RoleMenuViewModel; var rolePermissionList = roleMenuPermissionVm.RolePermissionViewModel; if ((roleMenuList == null || roleMenuList.Count <= 0) && (rolePermissionList == null || rolePermissionList.Count <= 0)) { return(ResponseResult <bool> .GenSuccessResponse(false)); } var roleId = roleMenuList.FirstOrDefault().RoleId; if (roleId <= 0) { return(ResponseResult <bool> .GenSuccessResponse(false)); } _roleMenuService = GetService <RoleMenuService>(); _rolePermissionService = GetService <RolePermissionService>(); using (TransactionScope ts = new TransactionScope()) { var result = false; try { //先删除角色菜单记录,再添加新的 result = _roleMenuService.DeleteRoleMenus((int)roleId); foreach (var roleMenu in roleMenuList) { result &= _roleMenuService.Add(roleMenu) > 0; } //先删除角色操作记录,在添加新的 result &= _rolePermissionService.DeleteRolePermissions((int)roleId); foreach (var rolePermission in rolePermissionList) { result &= _rolePermissionService.Add(rolePermission) > 0; } ts.Complete(); } catch (Exception ex) { result = false; ts.Dispose(); } return(ResponseResult <bool> .GenSuccessResponse(result)); } }
public Task <IResultModel> Add(RoleMenuAddModel model) { return(_service.Add(model)); }