示例#1
0
        public PartialViewResult Category(int?ParentID, int?Category)
        {
            ViewBag.category = Category;
            var model = new ProductCategoryF().ProductCategories.Where(x => x.ParentID == ParentID).ToList();

            return(PartialView(model));
        }
示例#2
0
        public void SetViewBag(long?selectedID = null)
        {
            var f = new ProductCategoryF();

            ViewBag.CaterogyID = new SelectList(f.ProductCategories, "ID", "Name", selectedID);
            var Brand = new BrandF();

            ViewBag.BrandID = new SelectList(Brand.Brands, "ID", "Name", selectedID);
            var Country = new CountryF();

            ViewBag.CountryID = new SelectList(Country.Countrys, "ID", "Name", selectedID);
        }
示例#3
0
        public ActionResult Detail(long ID)
        {
            var model    = f.FindEntity(ID);
            var category = new ProductCategoryF().FindEntity(model.CaterogyID.GetValueOrDefault(-1));

            ViewBag.CategoryID = category.Name;
            var brand = new BrandF().FindEntity(model.BrandID.GetValueOrDefault(-1));

            ViewBag.BrandID = brand.Name;
            if (model != null)
            {
                return(View(model));
            }
            return(View());
        }
示例#4
0
        public PartialViewResult ProductList(Menu Parent)
        {
            ViewBag.menu = Parent;
            List <ProductCategory> category = new ProductCategoryF().ProductCategories.Where(x => x.ParentID == Parent.ID).ToList();
            List <Product>         product  = new ProductF().Products.ToList();
            List <Product>         model    = new List <Product>();

            foreach (Product item in product)
            {
                if (category.Exists(x => x.ID == item.CaterogyID))
                {
                    model.Add(new ProductF().FindEntity(item.ID));
                }
            }
            return(PartialView(model));
        }
示例#5
0
        public ActionResult Index(int?ParentID)
        {
            ViewBag.parentID = ParentID;
            List <ProductCategory> category = new ProductCategoryF().ProductCategories.Where(x => x.ParentID == ParentID).ToList();
            List <Product>         product  = new ProductF().Products.ToList();
            List <Product>         model    = new List <Product>();

            foreach (Product item in product)
            {
                if (category.Exists(x => x.ID == item.CaterogyID))
                {
                    model.Add(new ProductF().FindEntity(item.ID));
                }
            }
            return(View(model));
        }
示例#6
0
        public ActionResult Index(int?Category, int?Brand, string OrderBy, decimal?PriceMin, decimal?PriceMax, int?page, int?NumberPage)
        {
            List <Product> model = new ProductF().Products.ToList();

            ViewBag.category   = Category;
            ViewBag.brand      = Brand;
            ViewBag.orderby    = OrderBy;
            ViewBag.pricemin   = PriceMin;
            ViewBag.pricemax   = PriceMax;
            ViewBag.numberpage = NumberPage;
            if (Category != null)
            {
                model = model.Where(x => x.CaterogyID == Category).ToList();
                ProductCategory category = new ProductCategoryF().FindEntity(Category.GetValueOrDefault(0));
                ViewBag.parentID = category.ParentID;
            }
            if (Brand != null)
            {
                model = model.Where(x => x.BrandID == Brand).ToList();
            }
            if (PriceMin != null && PriceMax != null)
            {
                model = model.Where(x => x.Price >= PriceMin && x.Price <= PriceMax).ToList();
            }
            if (OrderBy == "Name")
            {
                model = model.OrderBy(x => x.Name).ToList();
            }
            else if (OrderBy == "Price")
            {
                model = model.OrderBy(x => x.Price).ToList();
            }
            else
            {
                model = model.OrderBy(x => x.ID).ToList();
            }

            return(View(model.ToPagedList(page ?? 1, NumberPage ?? 3)));
        }
示例#7
0
        public ActionResult Index()
        {
            var model = new ProductCategoryF().ProductCategories.ToList();

            return(View(model));
        }