예제 #1
0
        static async Task Main(string[] args)
        {
            var channel       = GrpcChannel.ForAddress("https://localhost:5001");
            var productClient = new Product.ProductClient(channel);

            var clientRequested = new ProductLookupModel {
                ProductId = 1
            };

            var product = await productClient.GetUserWelcomeAsync(clientRequested);

            Console.WriteLine($"{ product.UserWelcome} {product.UserName} ");
            Console.WriteLine();
            Console.WriteLine();

            using (var call = productClient.GetProductList(new ProductListRequest()))
            {
                while (await call.ResponseStream.MoveNext())
                {
                    var currentProduct = call.ResponseStream.Current;

                    Console.WriteLine("New Product List");
                    Console.WriteLine();
                    Console.WriteLine($" Product Name:{ currentProduct.ProductName} Product Type: { currentProduct.ProductType} Product Description: { currentProduct.ProductDesc} Price: { currentProduct.Price} ");


                    Console.WriteLine();
                }
            }


            Console.ReadLine();
        }
예제 #2
0
        public ActionResult Lookup(ProductLookupModel searchModel)
        {
            var searchedProductsModel = new ProductLookupModel
            {
                ProductItems    = productService.GetProductItems(searchModel.SearchText, searchModel.includeInactive),
                includeInactive = searchModel.includeInactive
            };


            return(View("Lookup", searchedProductsModel));
        }
예제 #3
0
        public override Task <ProductModel> GetUserWelcome(ProductLookupModel request, ServerCallContext context)
        {
            ProductModel output = new ProductModel();

            if (request.ProductId == 1)
            {
                output.UserName    = "******";
                output.UserWelcome = "Welcome";
            }
            else if (request.ProductId == 2)
            {
                output.UserName    = "******";
                output.UserWelcome = "Welcome";
            }
            else
            {
                output.UserName    = "******";
                output.UserWelcome = "Welcome";
            }

            return(Task.FromResult(output));
        }