コード例 #1
0
        public override Task <PlatformReply> GetAllPlaforms(GettAllRequest request, ServerCallContext context)
        {
            var platforms           = _repo.GetAtllPlatforms();
            var grpcPlatformReplies = _mapper.Map <RepeatedField <GrpcPlatformReply> >(platforms);

            var platformReply = new PlatformReply();

            platformReply.Platforms.AddRange(grpcPlatformReplies);

            return(Task.FromResult(platformReply));
        }
コード例 #2
0
        public IEnumerable <Platform> GetAllPlatforms()
        {
            Console.WriteLine($"--> Calling Grpc Service: {_configuration["GrpcPlatform"]}");

            var platforms = new List <Platform>();
            var channel   = GrpcChannel.ForAddress(_configuration["GrpcPlatform"]);
            var client    = new GrpcPlatform.GrpcPlatformClient(channel);
            var request   = new GettAllRequest();

            try
            {
                var response = client.GetAllPlaforms(request);
                platforms = _mapper.Map <List <Platform> >(response.Platforms);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"--> Could not call Grpc Server: {ex.Message}");
            }

            return(platforms);
        }