Beispiel #1
0
        //Order by Category
        public ActionResult Price()
        {
            RentingWebsiteEntities db = new RentingWebsiteEntities();
            var products = db.Products.Include(p => p.FitProduct)
                           .Include(p => p.Image);

            products = db.Products
                                                                          //Update the Catalog so that the Index action will filter the Product objects
                       .Where(p => p.Price == null || p.Price == p.Price) //If category is not null, only those Product objects with a matching Category property are selected
                       .OrderBy(p => p.ProductId);

            return(View());
        }
        // Integrate a child action to include the output from an arbitrary action method in the current view
        //GET: Nav and create the list of categories on the right sidebar
        public PartialViewResult Nav(string category = null)
        {
            RentingWebsiteEntities db = new RentingWebsiteEntities();

            ViewBag.SelectedCategory = category; //the ViewBag allows us to pass data from the controller to the view without using a view model.
            IEnumerable <string> categories = db.Products
                                              .Select(x => x.Category)
                                              .Distinct()
                                              .OrderBy(x => x);

            return(PartialView(categories));

            //ViewBag.SelectedSize = size; //the ViewBag allows us to pass data from the controller to the view without using a view model.
            //IEnumerable<string> sizes = db.Products
            //.Select(x => s.Size)
            //.Distinct()
            //.OrderBy(s => s);
            //return PartialView(sizes;
        }