예제 #1
0
        public RedirectToRouteResult AddToCart(Cart cart, int Id, string returnUrl)
        {
            Product product = productManager.ReadAll().FirstOrDefault(p => p.Id == Id);

            if (product != null)
            {
                cart.AddItem(product, 1);
            }
            return(RedirectToAction("Index", new { returnUrl }));
        }
예제 #2
0
        public ActionResult ProcessedOrder(List <OrderSummary> orders, int Id)
        {
            var order = orderManager.ReadAll().FirstOrDefault(x => x.Id == Id);

            if (ModelState.IsValid)
            {
                orderManager.Update(order);
                TempData["message"] = string.Format("{0} заказ был успешно обработан.", order.Id);
                return(RedirectToAction("OrderList"));
            }
            return(RedirectToAction("OrderList"));
        }
예제 #3
0
        public PartialViewResult Menu(string category = null)
        {
            ViewBag.SelectedCategory = category;
            IEnumerable <string> categories = productManager.ReadAll()
                                              .Select(x => x.Category)
                                              .Distinct()
                                              .OrderBy(x => x);

            return(PartialView(categories));
        }
예제 #4
0
        public PartialViewResult List(string category, int page = 1)
        {
            Thread.Sleep(1000);
            var model = new ProductListViewModel
            {
                Products =
                    ((List <Product>)productManager.ReadAll()).Where(p => category == null || p.Category.Unidecode() == category)
                    .OrderBy(p => p.Price)
                    .Skip((page - 1) * PageSize)
                    .Take(PageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = ((List <Product>)productManager.ReadAll()).Count(p => category == null || p.Category.Unidecode() == category)
                },
                CurrentCategory = category
            };

            return(PartialView(model));
        }
예제 #5
0
 public ViewResult Index()
 {
     return(View(productManager.ReadAll()));
 }