コード例 #1
0
        // GET: api/Subcategory
        public HttpResponseMessage Get()
        {
            var subcategories = mgr.GetAll();

            subcategories.ForEach(x => { x.Image = "/Content/images/" + x.Image; });
            if (subcategories != null)
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, subcategories));
            }
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
コード例 #2
0
        public HttpResponseMessage getCategoryAndSubcategory()
        {
            var categories    = mgrCate.GetAll();
            var subcategories = mgrSubcate.GetAll();
            var products      = mgrPro.getProducts();

            categories.ForEach(x =>
            {
                x.Image = "/Content/images/" + x.Image;
            });
            subcategories.ForEach(x =>
            {
                x.Image = "/Content/images/" + x.Image;
            });
            products.ForEach(x =>
            {
                x.ProductImages.ForEach(y =>
                {
                    y.Image = "/Content/images/" + y.Image;
                });
            });
            var obj = new { categories = categories, subcategories = subcategories, products = products };

            return(this.Request.CreateResponse(HttpStatusCode.OK, obj));
        }