public ActionResult SearchAjax(WebService.SearchModel model) { model.StoreId = StoreID; string pageQuery = Request.QueryString["page"]; SearchResult rs = new SearchResult(); int page = 1; if (!string.IsNullOrEmpty(pageQuery)) { page = Convert.ToInt32(pageQuery); } WebService.AnperoService sv = new WebService.AnperoService(); //if (!string.IsNullOrEmpty(model.ParentCategory) && model.ParentCategory!="0") //{ // rs = sv.GetProductByParentCategory(StoreID, TokenKey, Convert.ToInt32(model.ParentCategory), model.Page, model.PageSize, 0); //} //else if (!string.IsNullOrEmpty(model.Category) && model.Category != "0") //{ // rs = sv.GetProductByCategory(StoreID, TokenKey, Convert.ToInt32(model.Category), model.Page, model.PageSize, 0); //} //else //{ sv.SearchProducts(StoreID, TokenKey, model); //rs = sv.SearchProduct(StoreID, TokenKey, model); //} ViewData["productList"] = rs; if (rs != null) { ViewBag.page = Anpero.Paging.setupAjaxPage(model.Page, model.PageSize, rs.ResultCount, 10, "Search.Products", model.SortBy); } return(PartialView("SearchAjax")); }
private void GetNewestProduct() { WebService.AnperoService service = new WebService.AnperoService(); WebService.SearchResult searchResult = new WebService.SearchResult(); int shortCacheTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["shortCacheTime"]); if (HttpRuntime.Cache["newestProduct"] != null) { searchResult = (WebService.SearchResult)HttpRuntime.Cache["newestProduct"]; } else { WebService.SearchModel saearchFilter = new WebService.SearchModel(); saearchFilter.CurentPage = 1; saearchFilter.PageSize = 7; searchResult = service.SearchProducts(StoreID, TokenKey, saearchFilter); searchResult = service.SearchProduct(StoreID, TokenKey, "0", "0", "0", 0, int.MaxValue, 1, 7, "", SearchOrder.TimeDesc, 0, ""); if (searchResult != null) { HttpRuntime.Cache.Insert("newestProduct", searchResult, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); } } ViewData["newestProduct"] = searchResult; //WebService.SearchResult searchResult2 = new WebService.SearchResult(); //if (HttpRuntime.Cache["customProduct"] != null) //{ // searchResult = (WebService.SearchResult)HttpRuntime.Cache["customProduct"]; //} //else //{ // searchResult = service.GetProductByParentCategory(StoreID, TokenKey, 178, 1, 8, 0); // if (searchResult != null) // { // HttpRuntime.Cache.Insert("customProduct", searchResult, null, DateTime.Now.AddMinutes(shortCacheTime), TimeSpan.Zero); // } //} //ViewData["customProduct"] = searchResult; }