Пример #1
0
        public override async Task <Any> OnInvoke(InvokeEnvelope request, ServerCallContext context)
        {
            switch (request.Method)
            {
            case "GetAllProducts":
                ProductListRequest         productListRequest = ProductListRequest.Parser.ParseFrom(request.Data.Value);
                ProductList.V1.ProductList productsList       = await _productListService.GetAllProducts(productListRequest, context);

                return(Any.Pack(productsList));
            }
            return(null);
        }
Пример #2
0
        public override async Task <ProductList.V1.ProductList> GetAllProducts(ProductListRequest request, ServerCallContext context)
        {
            IList <Product> results = await _productContext.Products.ToListAsync();

            var productList = new ProductList.V1.ProductList();

            foreach (Product item in results)
            {
                productList.Results.Add(new ProductList.V1.Product
                {
                    ID = item.ProductID.ToString()
                });
            }

            return(productList);
        }