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 })); }
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")); }
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)); }
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)); }
public ViewResult Index() { return(View(productManager.ReadAll())); }