Exemple #1
0
        public async Task <RpcResponse> Post(UserGrpcEdit userInfo)
        {
            var client = (await _serviceDiscover.FindServiceAsync <UserRpcService>()) as IUserRpcServiceClient;
            var reply  = await client.SaveUserAsync(userInfo);

            return(reply);
        }
Exemple #2
0
        public override Task <RpcResponse> SaveUser(UserGrpcEdit request, ServerCallContext context)
        {
            var userInfo = _users.FirstOrDefault(u => u.Uid == request.Uid);

            if (userInfo != null)
            {
                return(Task.FromResult(new RpcResponse()
                {
                    Code = "500", Message = $"当前用户:{userInfo.Uid}已存在,不允许重复保存"
                }));
            }

            _users.Add(request);
            return(Task.FromResult(new RpcResponse()
            {
                Code = "200", Message = "保存成功!"
            }));
        }