Example #1
0
        //给角色添加权限
        public int User_RoleToRights_Add(RelateRoleToRightAddViewModel relateRoleToRightAddViewModel)
        {
            //获取视图集合
            List <RelateRoleRightAddMiddlecs> relateRightIdandRoleIdList = relateRoleToRightAddViewModel.RelateRightIdandRoleIdList;
            //将视图模型和转为领域模型集合
            List <User_Relate_Role_Right> Relate_Role_Rights = _IMapper.Map <List <RelateRoleRightAddMiddlecs>, List <User_Relate_Role_Right> >(relateRightIdandRoleIdList);

            int AddNum = _userRelateRoleRightRepository
                         .RelateRoleToRightsAdd(Relate_Role_Rights);

            return(AddNum);
        }
        public ActionResult <RelateRoleToRightAddResModel> Manage_UserRoleToRight_Add(RelateRoleToRightAddViewModel relateRoleToRightAddViewModel)
        {
            RelateRoleToRightAddResModel relateRoleToRightAddResModel = new RelateRoleToRightAddResModel();
            int AddRowNum = _roleService.User_RoleToRights_Add(relateRoleToRightAddViewModel);

            if (AddRowNum > 0)
            {
                relateRoleToRightAddResModel.IsSuccess                  = true;
                relateRoleToRightAddResModel.AddCount                   = AddRowNum;
                relateRoleToRightAddResModel.baseViewModel.Message      = "角色分配权限成功";
                relateRoleToRightAddResModel.baseViewModel.ResponseCode = 200;
                _ILogger.Information("给角色配置权限成功");
                return(Ok(relateRoleToRightAddResModel));
            }
            else
            {
                relateRoleToRightAddResModel.IsSuccess                  = false;
                relateRoleToRightAddResModel.AddCount                   = 0;
                relateRoleToRightAddResModel.baseViewModel.Message      = "角色分配权限失败";
                relateRoleToRightAddResModel.baseViewModel.ResponseCode = 400;
                _ILogger.Information("给角色配置权限失败");
                return(BadRequest(relateRoleToRightAddResModel));
            }
        }