コード例 #1
0
        public ProductList GetHomeList()
        {
            ProductList productList = new ProductList();

            c.BaseAddress = new Uri(url);
            c.DefaultRequestHeaders.Accept.Clear();
            c.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json")
            );

            HttpResponseMessage response = c.GetAsync("api/product/all").Result;
            productList = response.Content.ReadAsAsync<ProductList>().Result;
           
            return productList;
        }
コード例 #2
0
        public ProductList SearchAdvance(SearchModel search)
        {
            ProductList list = new ProductList();

            c.BaseAddress = new Uri(url);
            c.DefaultRequestHeaders.Accept.Clear();
            c.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")
            );

            HttpResponseMessage response = c.PostAsJsonAsync( "api/product/SearchAdvance",search).Result;
            list = response.Content.ReadAsAsync<ProductList>().Result;

            list.newPageList = list.newList.ToPagedList(1, 20);
           
            return list;
        }
コード例 #3
0
 public static void SetProductSession(ProductList prolist, string type)
 {
     HttpContext.Current.Session[type] = prolist;
 }
コード例 #4
0
        public ProductList GetProductList(string name, int id,int ? page)
        {
            ProductList productList = new ProductList();

            c.BaseAddress = new Uri(url);
            c.DefaultRequestHeaders.Accept.Clear();
            c.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json")
            );

            if (SessionHelper.GetProductSession(name + id) == null)
            {
                HttpResponseMessage response = c.GetAsync("api/product/ByNameID/" + name + "/" + id).Result;
                productList = response.Content.ReadAsAsync<ProductList>().Result;
                SessionHelper.SetProductSession(productList, name + id);
            }
            else
            {
                productList = SessionHelper.GetProductSession(name + id);

            }
        
           
            int pageNum = (page ?? 1);
            productList.newPageList = productList.newList.ToPagedList(pageNum, 9);
           
            return productList;
        }