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; }
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; }
public static void SetProductSession(ProductList prolist, string type) { HttpContext.Current.Session[type] = prolist; }
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; }