Пример #1
0
        public async Task <ActionResult> DisplayProducts()
        {
            List <Product>    lstProducts    = null;
            ProductOrder      productOrder   = new ProductOrder();
            List <AddProduct> lstAddProducts = new List <AddProduct>();

            string value = cache.StringGet("Products");

            if (null != value)
            {
                lstProducts = JsonConvert.DeserializeObject <List <Product> >(value);
            }
            else
            {
                lstProducts = await azureDocDBHelper.GetProducts();

                value = JsonConvert.SerializeObject(lstProducts);
                cache.StringSet("Products", value);
            }
            foreach (Product pd in lstProducts)
            {
                AddProduct addPd = new AddProduct();
                addPd.ProductId   = pd.ProductId;
                addPd.ProductName = pd.ProductName;
                addPd.UnitPrice   = pd.UnitPrice;
                lstAddProducts.Add(addPd);
            }
            productOrder.lstProducts = lstAddProducts;
            return(View(productOrder));
        }
Пример #2
0
        public async Task <ActionResult> DisplayProducts()
        {
            List <Product>    lstProducts;
            ProductOrder      productOrder   = new ProductOrder();
            List <AddProduct> lstAddProducts = new List <AddProduct>();

            lstProducts = await azureDocDBHelper.GetProducts();

            foreach (Product pd in lstProducts)
            {
                AddProduct addPd = new AddProduct();
                addPd.ProductId   = pd.ProductId;
                addPd.ProductName = pd.ProductName;
                addPd.UnitPrice   = pd.UnitPrice;
                lstAddProducts.Add(addPd);
            }
            productOrder.lstProducts = lstAddProducts;
            return(View(productOrder));
        }
Пример #3
0
        public async Task <ProductResource> Get()
        {
            List <Product> listProductDetails;

            listProductDetails = await azureDocDBHelper.GetProducts();

            ProductResource productResource = new ProductResource();

            productResource.ProductsAvailable = listProductDetails;
            return(productResource);
        }