public IActionResult ShopList(ShopListOptions options) { var repo = new EcomRepository(); var cart = PageMaster.GetShoppingCart(); int total; var model = new ShopListModel { ShopList = repo.GetShopList(options, cart, out total), Brands = repo.GetAllBrands() }; options.TotalItems = total; ViewBag.Options = options; ViewBag.CountCartItems = cart.CartProducts != null?cart.CartProducts.Count() : 0; return(View(model)); }
public IActionResult ProductDetail(int id) { ShoppingCart cart = PageMaster.GetShoppingCart(); Product product = Repository.GetProductById(id); var model = new ProductDetailModel(); model.Product = product; model.IsAddedToCart = Repository.IsAddedToCart(product, cart); model.BrandAlso = Repository.GetProducstByBrand(product.BrandId) .Where(p => p.Id != product.Id) .Select(p => Repository.GetShopListItem(p, cart)) .Take(5); model.CategoryAlso = Repository.GetProductsByCategory(product.CategoryId) .Where(p => p.Id != product.Id) .Select(p => Repository.GetShopListItem(p, cart)) .Take(5); model.Reviews = Repository.GetProductReviews(product.Id); ViewBag.CountCartItems = cart.CartProducts.Count(); return(View(model)); }