示例#1
0
        public async Task TestUpdate()
        {
            var products1 = await _pManager.GetAllProducts();

            products1[0].Price = 12.00M;
            var p = await _pManager.UpdateProduct(products1[0].ProductId, products1[0]);

            Assert.AreEqual <decimal>(p.Price, 12.00M);
        }
        //Var db = new List<Product>();
        // GET: api/Products
        public async Task <IEnumerable <Product> > GetProducts(int?pageNumber = null, int?pageSize = null)
        {
            var products = await _productManager.GetAllProducts(pageNumber, pageSize);

            foreach (var p in products)
            {
                if (!string.IsNullOrEmpty(p.ImageAddress))
                {
                    try
                    {
                        p.Base64Image    = Convert.ToBase64String(System.IO.File.ReadAllBytes(p.ImageAddress));
                        p.Base64Thumbnil = Convert.ToBase64String(System.IO.File.ReadAllBytes(p.ImageAddress.Replace("UserImages", "UserThumbnils")));
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            return(products);
        }