Example #1
0
        public ActionResult Index()
        {
            List <int> topProductsIds = Utl.Preferences((int?)Session["accountID"], -1);

            ViewBag.TopProducts = db.Products.Where(p => topProductsIds.Any(t => t == p.ProductID));// db.Products.Where(p => topProductsIds.Contains(p.ProductID)).ToList();
            return(View(db.Categories.ToList()));
        }
Example #2
0
        // GET: Products/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Product product = db.Products.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }

            int?accountID = Utl.IsLoggedIn(Session) ? (int)Session["accountID"] : -1;
            var prefs     = Utl.Preferences(accountID, (int)id);

            ViewBag.Preferences  = Utl.PopulateProducts(prefs);
            ViewBag.CategoryName = db.Categories.Where(c => c.CategoryID == product.CategoryID).ToList()[0].Name;
            return(View(product));
        }