public async Task <string> GetStudentByID(int id) { var studentClient = new RemoteStudent.RemoteStudentClient(channel); var studentInput = new StudentLookupModel { StudentId = id }; var studentReply = await studentClient.GetStudentInfoAsync(studentInput); // Console.WriteLine($"{studentReply.FirstName} { studentReply.LastName}"); // var name = return(studentReply.LastName + " " + studentReply.FirstName); //AppContext.SetSwitch( // "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", // true); //var httpClient = new HttpClient(); //httpClient.BaseAddress = new Uri("http://localhost:50051"); //var client = Grpc.Net.Client.GrpcChannel GrpcClient.Create<grpcGreeter.Greeter.GreeterClient>(httpClient); //grpcGreeter.HelloReply reply = await client.SayHelloAsync(new grpcGreeter.HelloRequest() { Name = name }); //return reply.Message; }
static async Task updateStudent(GrpcChannel channel, StudentModel student) { var client = new RemoteStudent.RemoteStudentClient(channel); var reply = await client.UpdateStudentAsync(student); Console.WriteLine(reply.Result); }
public async Task <string> AddNewStd(StudentModel aNewStudent) { var client = new RemoteStudent.RemoteStudentClient(channel); var reply = await client.InsertStudentAsync(aNewStudent); return(reply.ToString()); }
static async Task deleteStudent(GrpcChannel channel, int id) { var client = new RemoteStudent.RemoteStudentClient(channel); var input = new StudentLookupModel { StudentId = id }; var reply = await client.DeleteStudentAsync(input); Console.WriteLine(reply.Result); }
static async Task findStudentById(GrpcChannel channel, int id) { var client = new RemoteStudent.RemoteStudentClient(channel); var input = new StudentLookupModel { StudentId = id }; var reply = await client.GetStudentInfoAsync(input); Console.WriteLine($"{reply.FirstName} {reply.LastName}"); }
static async Task Main(string[] args) { var channel = GrpcChannel.ForAddress("https://localhost:5001"); var studentClient = new RemoteStudent.RemoteStudentClient(channel); var studentInput = new StudentLookupModel { StudentId = 22 }; var studentReply = await studentClient.GetStudentInfoAsync(studentInput); Console.WriteLine($"{studentReply.FirstName} {studentReply.LastName}"); Console.ReadLine(); }
static async Task displayAllStudents(GrpcChannel channel) { var client = new RemoteStudent.RemoteStudentClient(channel); var empty = new Empty(); var list = await client.RetrieveAllStudentsAsync(empty); Console.WriteLine(">>>>>>>>>>>>>>>>>>++++++++++++<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); foreach (var item in list.Items) { Console.WriteLine($"{item.StudentId}: {item.FirstName} {item.LastName}"); } }
static async Task Main(string[] args) { //var input = new HelloRequest { Name = "Jane Bond" }; //var channel = GrpcChannel.ForAddress("https://localhost:5001"); //var client = new Greeter.GreeterClient(channel); //var reply = await client.SayHelloAsync(input); //Console.WriteLine(reply.Message); var channel = GrpcChannel.ForAddress("https://localhost:5001"); var studentClient = new RemoteStudent.RemoteStudentClient(channel); var studentInput = new StudentLookupModel { StudentId = 33 }; var studentReply = await studentClient.GetStudentInfoAsync(studentInput); Console.WriteLine($"{studentReply.FirstName} {studentReply.LastName}"); Console.ReadLine(); }