示例#1
0
        private static async Task GetUserById(int userId, User.UserClient userServiceClient)
        {
            var jwt = await GetJwt();

            var headers = new Metadata
            {
                { "Authorization", $"Bearer {jwt}" }
            };

            var getUserByIdViewModel = new GetUserByIdViewModel
            {
                UserId = userId,
            };

            try
            {
                var user = userServiceClient.GetUser(getUserByIdViewModel, headers);

                Console.WriteLine($"{user.Id} - {user.FirstName} {user.Surname} - {user.EmailAddress}");
            }
            catch (RpcException ex)
            {
                Console.WriteLine($"{ex.Status.StatusCode} - {ex.Status.Detail}");
            }
        }
示例#2
0
 public UserReply GetUserAsync(int id)
 {
     return(_userClient.GetUser(new IdRequest {
         Id = id
     }));
 }