Exemplo n.º 1
0
        public void GetWorksCorrectly()
        {
            ProductApi api    = new ProductApi();
            var        result = api.Get(new [] { "9788741201122", "9788702168044" });

            result.Count().Should().Be(2);
        }
Exemplo n.º 2
0
        public JsonResult getListProduct()
        {
            ProductApi         productApi         = new ProductApi();
            ProductCategoryApi productCategoryApi = new ProductCategoryApi();
            ProductImageApi    productImageApi    = new ProductImageApi();

            //get parent product
            var products = productApi.Get().Where(q => q.ParentProductId == null);

            if (products == null)
            {
                return(Json(new
                {
                    status = new
                    {
                        success = false,
                        status = ConstantManager.STATUS_SUCCESS,
                        message = ConstantManager.MES_FAIL
                    },
                    data = new { }
                }, JsonRequestBehavior.AllowGet));
            }

            var data = (from p in products
                        select new
            {
                product_image_list = productImageApi.Get().Where(q => q.ProductId == p.ID).ToList(),
                product_id = p.ID,
                product_name = p.Name,
                price = p.Price,
                cat_id = p.CategoryID,
                size = p.Size,
                color = p.Color
            }).ToList();

            //get product category
            var productCategory = productCategoryApi.Get();
            //get cateId and cateName
            var category = from pc in productCategory
                           select new
            {
                cat_id   = pc.ID,
                cat_name = pc.Name
            };

            return(Json(new
            {
                status = new
                {
                    success = true,
                    status = ConstantManager.STATUS_SUCCESS,
                    message = ConstantManager.MES_SUCCESS,
                },
                data = new
                {
                    data = new
                    {
                        product_list = data,
                        product_category_list = category.ToList()
                    }
                }
            }, JsonRequestBehavior.AllowGet));
        }