Exemplo n.º 1
0
        /// <summary>
        /// 返回记录总数 配合分页查询用
        /// </summary>
        /// <param name="sWhere">查询条件;多条件是目前只支持 and;表达式 System.Linq.Dynamic的形式</param>
        /// <returns>符合查询条件的记录数</returns>
        public int GetSysRoleCount(string sWhere)
        {
            Expression <Func <SysRole, bool> > whereLamda = SerializerHelper.ConvertParamWhereToLinq <SysRole>(sWhere);

            using (ISysRoleBLL SysRoleBLL = BLLContainer.Resolve <ISysRoleBLL>())
            {
                return(SysRoleBLL.GetCount(whereLamda));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加/修改角色
        /// </summary>
        /// <param name="userGroupDto"></param>
        /// <param name="objCheckMenus">角色的菜单权限</param>
        /// <returns></returns>
        public IActionResult AddorEditRole(SysRoleDto roleDto, List <SysMenuDto> objCheckMenus)
        {
            bool   bResult  = true;
            string sMessage = "保存成功";
            var    role     = AutoMapper.Mapper.Map <SysRole>(roleDto);

            if (_sysRoleBLL.GetCount(t => t.RoleName.Equals(role.RoleName) && !t.RoleId.Equals(role.RoleId) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted)) > 0)
            {
                sMessage = "角色名称不能重复";
                bResult  = !bResult;
            }
            else
            {
                //添加
                if (string.IsNullOrEmpty(role.RoleId))
                {
                    role.DeleteSign   = (Int32)DeleteSign.Sing_Deleted;
                    role.CreateUserId = _userAccount.GetUserInfo().UserId;
                    role.CreateTime   = DateTime.Now;
                    bResult           = _sysRoleBLL.Add(role);
                    bResult           = _sysRoleBLL.AddRoleMenu(role.RoleId, objCheckMenus).Result;
                }
                else//修改
                {
                    var userRole_Edit = _sysRoleBLL.GetModels(t => t.RoleId.Equals(role.RoleId)).SingleOrDefault();
                    userRole_Edit.RoleName = role.RoleName;
                    userRole_Edit.EditTime = DateTime.Now;
                    userRole_Edit.Note     = role.Note;
                    bResult = _sysRoleBLL.Update(userRole_Edit);
                    bResult = _sysRoleBLL.AddRoleMenu(userRole_Edit.RoleId, objCheckMenus).Result;
                }
            }
            return(Ok(new ResponseModel
            {
                RetCode = bResult ? StatesCode.success : StatesCode.failure,
                RetMsg = sMessage
            }));
        }