public override Task <GetPopularityRankingResponse> GetPopularityRankings(GetPopularityRankingRequest request, ServerCallContext context)
        {
            var response = new GetPopularityRankingResponse();
            var popRanks = _libraryService.GetPopularityRankings().Select(s => new PopularityRankingMessage()
            {
                Id = s.Id.ToString(), Name = s.Name
            });

            response.PopularityRankings.AddRange(popRanks);
            return(Task.FromResult(response));
        }
Beispiel #2
0
        public async Task <List <PopularityRankingModel> > GetPopularityRankingsAsync()
        {
            var channel = new Channel(channelTarget, ChannelCredentials.Insecure);

            try
            {
                var client  = new LibraryGrpcService.LibraryGrpcServiceClient(channel);
                var request = new GetPopularityRankingRequest()
                {
                };

                var response           = client.GetPopularityRankings(request);
                var popularityRankings = response.PopularityRankings.Select(s => PopularityRankingGrpcConverter.ToMessage(s)).ToList();
                return(popularityRankings);
            }
            finally
            {
                await channel.ShutdownAsync();
            }
        }