Ejemplo n.º 1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="mSysRole">模型</param>
 /// <returns>是否成功</returns>
 public bool UpdateSysRole(SysRole mSysRole)
 {
     if (mSysRole == null)
     {
         return(false);
     }
     using (ISysRoleBLL SysRoleBLL = BLLContainer.Resolve <ISysRoleBLL>())
     {
         return(SysRoleBLL.Update(mSysRole));
     }
 }
Ejemplo 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
            }));
        }