public override Task <GetRecommendedSongsResponse> GetRecommendedSongs(GetRecommendedSongsRequest request, ServerCallContext context) { var filter = new BasicPageFilter() { UserId = Guid.Parse(request.UserId), PageIndex = request.PageIndex, PageSize = request.PageSize }; var songs = _libraryService.GetRecommendedSongs(filter); var response = new GetRecommendedSongsResponse(); response.Songs.AddRange(songs.Select(s => SongGrpcConverter.ToMessage(s)).ToList()); return(Task.FromResult(response)); }
public async Task <List <SongModel> > GetRecommendedSongsAsync(BasicPageFilter filter) { var channel = new Channel(channelTarget, ChannelCredentials.Insecure); try { var client = new LibraryGrpcService.LibraryGrpcServiceClient(channel); var request = new GetRecommendedSongsRequest() { UserId = filter.UserId.ToString(), PageIndex = filter.PageIndex, PageSize = filter.PageSize }; var response = await client.GetRecommendedSongsAsync(request); return(response.Songs.Select(s => SongGrpcConverter.ToMessage(s)).ToList()); } finally { await channel.ShutdownAsync(); } }