public ActionResult LoadMoreProducts(int skipCount, int section, int category) { var sectionCatId = db.SectionCategories.Where(s => s.SectionId == section && s.CategoryId == category).First().Id; var productImages = db.Products.Where(s => s.SectionCategoryId == sectionCatId) .OrderByDescending(m => m.Id) .Skip(skipCount) .Take(8) .ToList(); var user = Session["user"] as User; if (user == null) { Shop_VM vm2 = new Shop_VM { Products = productImages }; return(PartialView("_loadProducts", vm2)); } Shop_VM vm = new Shop_VM { User = Session["user"] as User, Favorites = db.Favorites.ToList(), Products = productImages }; return(PartialView("_loadProducts", vm)); }
public ActionResult Cart() { var user = Session["user"] as User; Shop_VM shop_VM = new Shop_VM() { Favorites = db.Favorites.Where(x => x.UserId == user.Id).ToList(), }; return(PartialView("~/Views/AJAX/Cart.cshtml", shop_VM)); }
// GET: Shop public ActionResult Index(int?Id, int?catId) { if (Id == null) { return(HttpNotFound()); } if (catId != null) { var sectCatId = db.SectionCategories.Where(s => s.SectionId == Id && s.CategoryId == catId).First().Id; var selectedProducts = db.Products.Where(s => s.SectionCategoryId == sectCatId).OrderByDescending(x => x.Id).Take(6).ToList(); ViewBag.productCount = db.Products.Where(s => s.SectionCategoryId == sectCatId).Count(); ViewBag.sectionId = Id; ViewBag.categoryId = catId; var shopHeader = db.ShopHeader.First(); Shop_VM vm = new Shop_VM { Products = selectedProducts, Favorites = db.Favorites.ToList(), User = Session["user"] as User, ShopHeader = shopHeader }; return(View(vm)); } var catSe = db.SectionCategories.Where(s => s.SectionId == Id).First().Id; ViewBag.sectionId = Id; ViewBag.categoryId = 1; var list = db.Products.Where(s => s.SectionCategoryId == catSe).OrderByDescending(x => x.Id).Take(6).ToList(); Shop_VM vm2 = new Shop_VM { ShopHeader = db.ShopHeader.First(), Favorites = db.Favorites.ToList(), User = Session["user"] as User, Products = list }; ViewBag.productCount = db.Products.Where(s => s.SectionCategoryId == catSe).Count(); return(View(vm2)); }