Esempio n. 1
0
        public async Task <BasketData> GetById(string id)
        {
            return(await GrpcCallerService.CallService(_urls.GrpcBasket, async channel =>
            {
                var client = new Basket.BasketClient(channel);
                _logger.LogDebug("grpc client created, request = {@id}", id);
                var response = await client.GetBasketByIdAsync(new BasketRequest {
                    Id = id
                });
                _logger.LogDebug("grpc response {@response}", response);

                return MapToBasketData(response);
            }));
        }
 public async Task <IEnumerable <CatalogItem> > GetCatalogItemsAsync(IEnumerable <int> ids)
 {
     return(await GrpcCallerService.CallService(_urls.GrpcCatalog, async channel =>
     {
         var client = new CatalogClient(channel);
         var request = new CatalogItemsRequest {
             Ids = string.Join(",", ids), PageIndex = 1, PageSize = 10
         };
         _logger.LogInformation("grpc client created, request = {@request}", request);
         var response = await client.GetItemsByIdsAsync(request);
         _logger.LogInformation("grpc response {@response}", response);
         return response.Data.Select(this.MapToCatalogItemResponse);
     }));
 }
Esempio n. 3
0
        public async Task <OrderData> GetOrderDraftAsync(BasketData basketData)
        {
            return(await GrpcCallerService.CallService(_urls.GrpcOrdering, async channel =>
            {
                var client = new OrderingGrpc.OrderingGrpcClient(channel);
                _logger.LogDebug(" grpc client created, basketData={@basketData}", basketData);

                var command = MapToOrderDraftCommand(basketData);
                var response = await client.CreateOrderDraftFromBasketDataAsync(command);
                _logger.LogDebug(" grpc response: {@response}", response);

                return MapToResponse(response, basketData);
            }));
        }
 public async Task <CatalogItem> GetCatalogItemAsync(int id)
 {
     return(await GrpcCallerService.CallService(_urls.GrpcCatalog, async channel =>
     {
         var client = new CatalogClient(channel);
         var request = new CatalogItemRequest {
             Id = id
         };
         _logger.LogInformation("grpc client created, request = {@request}", request);
         var response = await client.GetItemByIdAsync(request);
         _logger.LogInformation("grpc response {@response}", response);
         return MapToCatalogItemResponse(response);
     }));
 }