// GET: ShoppingCart public ActionResult Index(string searchString, int?page) { if (Session[CommonConstants.ShoppingCartSession] == null) { Session[CommonConstants.ShoppingCartSession] = new List <ShoppingCartViewModel>(); } var cart = new ShoppingCartViewModel(); int defaultPageSize = int.Parse(ConfigHelper.GetByKey("pageSizeAjax")); var common = new CommonController(_productService); int currentPageIndex = page ?? 1; cart.ListProducts = common.ProductListAjax(page, searchString).ToPagedList(currentPageIndex, defaultPageSize); if (Request.IsAjaxRequest()) { return(PartialView("_AjaxProductList", cart.ListProducts)); } return(View(cart)); }
public ActionResult Detail(long id, string searchString, int?page) { var viewCounter = (List <ViewCounterViewModel>)Session[CommonConstants.ViewCounterSession]; int defaultPageSize = int.Parse(ConfigHelper.GetByKey("pageSizeAjax")); var product = _productService.FindById(id); IncreaseView(viewCounter, id); var productVm = Mapper.Map <Product, ProductViewModel>(product); var relatedProducts = _productService.GetRelatedProducts(id, 5); var hotProducts = _productService.GetRelatedProducts(id, 5); List <string> listImages = new JavaScriptSerializer().Deserialize <List <string> >(productVm.MoreImages); var categoryVm = Mapper.Map <ProductCategory, ProductCategoryViewModel>(_productCategoryService.FindById(productVm.CategoryID)); ViewBag.Category = categoryVm; ViewBag.MoreImages = listImages; ViewBag.RelatedProducts = Mapper.Map <IEnumerable <Product>, IEnumerable <ProductViewModel> >(relatedProducts); ViewBag.Tags = Mapper.Map <IEnumerable <Tag>, IEnumerable <TagViewModel> >(_productService.GetTagsByProduct(id)); bool canReview = false; if (User.Identity.IsAuthenticated) { var userId = User.Identity.GetUserId(); canReview = reviewService.CanReview(id, userId); } ViewBag.CanReview = canReview; CommonController common = new CommonController(_productService); int currentPageIndex = page.HasValue ? page.Value : 1; productVm.ListProducts = common.ProductListAjax(page, searchString).ToPagedList(currentPageIndex, defaultPageSize); if (Request.IsAjaxRequest()) { return(PartialView("_AjaxProductList", productVm.ListProducts)); } else { return(View(productVm)); } }