public async Task <StudentDto> GetSmallPayloadAsync()
 {
     return((await _client.GetStudentAsync(
                 new GetStudentRequestDto()
     {
         Id = "5eeffdd1a28671a6e62dbda2"
     }
                 )).Student);
 }
Esempio n. 2
0
        public async Task <Models.Student> GetItemAsync(string id)
        {
            using var channel = GrpcChannel.ForAddress(serverAddress);
            var client = new StudentService.StudentServiceClient(channel);

            var item = await client.GetStudentAsync(new StudentId { Id = id });

            Models.Student foundstudent = new Models.Student()
            {
                AdmisstionDate = item.AdmisstionDate.ToDateTime(),
                DateofBirth    = item.DateofBirth.ToDateTime(),
                Id             = item.Id,
                FirstName      = item.FirstName,
                LastName       = item.LastName,
                MiddleName     = item.MiddleName,
                MobileNumber   = item.MobileNumber,
                UrduName       = item.UrduName
            };
            return(await Task.FromResult(foundstudent));
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            //AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            var channel = GrpcChannel.ForAddress("https://localhost:5001");

            var client = new StudentService.StudentServiceClient(channel);

            while (true)
            {
                Console.WriteLine("Enter an argument");

                string line = Console.ReadLine();

                if (line == "exit")
                {
                    break;
                }

                var reply = await client.GetStudentAsync(
                    new GetStudentRequest()
                {
                    Id = line
                }
                    );

                if (reply.Student != null)
                {
                    Console.WriteLine("Reply: " + reply.Student);
                }

                if (reply.Error != null)
                {
                    Console.WriteLine("Reply: " + reply.Error);
                }
            }
            Console.WriteLine("Exiting...");
        }