Esempio n. 1
0
        private async Task Update(bool error = false)
        {
            if (error)
            {
                Error();
            }
            Console.WriteLine("    Update    ");
            Console.WriteLine("++++++++++++++");
            Console.WriteLine("");
            Console.WriteLine("Enter the agent ID# you wish to update:");
            var idNumber = Console.ReadLine().Trim();

            Console.WriteLine("Enter the new agent name:");
            var name = Console.ReadLine().Trim();

            Console.WriteLine("Enter the new agent contact number:");
            var contact = Console.ReadLine().Trim();

            //Make update web call
            if (int.TryParse(contact, out int contactNumber) && int.TryParse(idNumber, out int id))
            {
                var request = new AgentModel {
                    Id = id, Name = name.Trim(), ContactNumber = contactNumber
                };
                var channel = GrpcChannel.ForAddress("https://localhost:5001");
                var client  = new AgentManagerService.AgentManagerServiceClient(channel);
                var reply   = await client.UpdateAsync(request);
                await PrintResults(reply.Response);
            }
        }