public RedirectToActionResult AddToBasket(int Id, string returnUrl)
        {
            Product product = _productRep.GetAll().Where(p => p.Id == Id).FirstOrDefault();

            if (product != null)
            {
                _basket.AddItem(product, 1);
            }
            return(RedirectToAction("Index", new { returnUrl }));
        }
Ejemplo n.º 2
0
        public ViewResult List(string category, int page)
        {
            ProductViewModel vm = new ProductViewModel()
            {
                Products =
                    _productRep.GetAll().Where(p => p.Category == category || category == null)
                    .OrderBy(p => p.Id)
                    .Skip((page - 1) * PSize)
                    .Take(PSize)
                ,
                CurrentCategory = category
                ,
                Paging = new PagingInfo()
                {
                    PageNumber = page
                    ,
                    PageSize = PSize
                    ,
                    ItemCount = _productRep.GetAll().Where(p => p.Category == category || category == null).Count()
                }
            };

            return(View(vm));
        }
 public IViewComponentResult Invoke()
 {
     ViewBag.SelectedCategory = RouteData?.Values["category"]; //???
     return(View(_productRep.GetAll().Select(x => x.Category).Distinct().OrderBy(x => x)));
 }
Ejemplo n.º 4
0
 public ViewResult Index()
 {
     return(View(_productRep.GetAll()));
 }