Esempio n. 1
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new CollegeService.CollegeServiceClient(channel);

            // Add New Professor
            NewProfessorRequest professorNew = new NewProfessorRequest()
            {
                Name    = "Shiva",
                Doj     = Timestamp.FromDateTime(DateTime.Now.AddYears(-5).ToUniversalTime()),
                Teaches = "CSharp, Java",
                Salary  = 1234.56,
                IsPhd   = true
            };
            var professorGenerated = await client.AddProfessorAsync(professorNew);

            // Retrieve Single Row
            var professorRequest = new GetProfessorRequest {
                ProfessorId = "5ec797ec-da0a-43df-b3a3-3f9a04163656"
            };
            var professor = await client.GetProfessorByIdAsync(professorRequest);

            DisplayProfessorDetails(professor);

            // Retrieve Multiple Rows
            var professors = await client.GetAllProfessorsAsync(new Empty());

            foreach (var prof in professors.Professors)
            {
                DisplayProfessorDetails(prof);
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Esempio n. 2
0
        protected override async Task OnInitializedAsync()
        {
            var client = new CollegeService.CollegeServiceClient(Channel);

            AllProfessors = await client.GetAllProfessorsAsync(new Empty());

            foreach (var professor in AllProfessors.Professors)
            {
                Professors.Add(GetProfessor(professor));
            }
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new CollegeService.CollegeServiceClient(channel);

            // Add New Professor
            NewProfessorRequest professorNew = new NewProfessorRequest()
            {
                Name    = "Shiva",
                Doj     = Timestamp.FromDateTime(DateTime.Now.AddYears(-5).ToUniversalTime()),
                Teaches = "CSharp, Java",
                Salary  = 1234.56,
                IsPhd   = true
            };
            var newlyAddedProfessor = await client.AddProfessorAsync(professorNew);

            WriteLine($"New Professor Added with Professor Id: {newlyAddedProfessor.ProfessorId}");

            WriteLine("Press any key to exit...");
            ReadKey();
        }
Esempio n. 4
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new CollegeService.CollegeServiceClient(channel);

            // Retrieve Single Row
            var professorRequest = new GetProfessorRequest {
                ProfessorId = "5ec797ec-da0a-43df-b3a3-3f9a04163656"
            };
            var professor = await client.GetProfessorByIdAsync(professorRequest);

            DisplayProfessorDetails(professor);

            // Retrieve Multiple Rows
            var professors = await client.GetAllProfessorsAsync(new Empty());

            foreach (var prof in professors.Professors)
            {
                DisplayProfessorDetails(prof);
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }