예제 #1
0
 private void BuildPage(CategoryProductModel model)
 {
     CategoryName.Text        = model.CategoryName;
     CategoryDescription.Text = model.CategoryDescription;
     Products.DataSource      = model.Products;
     Products.DataBind();
 }
예제 #2
0
        private void GetListofCategories()
        {
            var query = db.ProductTables.ToList();
            HashSet <string> Categories   = new HashSet <string>();
            Hashtable        CategoryHash = new Hashtable();

            foreach (ProductTable product in query)
            {
                string   catString = product.Categories;
                string[] splits    = catString.Split(',');
                foreach (string cat in splits)
                {
                    string normalizedCat = NormalizeString(cat);
                    if (CategoryHash.Contains(normalizedCat))
                    {
                        CategoryProductModel catProducts = (CategoryProductModel)CategoryHash[normalizedCat];
                        catProducts.mCategoryName = normalizedCat;
                        catProducts.mProduct.Add(product);
                        CategoryHash[normalizedCat] = catProducts;
                    }
                    else
                    {
                        CategoryProductModel catProducts = new CategoryProductModel();
                        catProducts.mCategoryName = normalizedCat;
                        catProducts.mProduct      = new List <ProductTable>();
                        catProducts.mProduct.Add(product);
                        CategoryHash.Add(normalizedCat, catProducts);
                    }
                }
            }
            ViewBag.ProductCategories = CategoryHash.Values.Cast <CategoryProductModel>().ToList();
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var model           = new CategoryProductModel();
            var currentcategory = SiteContext.Current.CatalogContext.CurrentCategory;

            model.CategoryName        = currentcategory.DisplayName();
            model.CategoryDescription = currentcategory.Description();
            model.Products            = MapProducts(UCommerce.Api.CatalogLibrary.GetProducts(currentcategory));
            BuildPage(model);
        }
        public virtual IActionResult ProductUpdate(CategoryProductModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            //try to get a product category with the specified id
            var productCategory = _categoryService.GetProductCategoryById(model.Id)
                                  ?? throw new ArgumentException("No product category mapping found with the specified id");

            productCategory.IsFeaturedProduct = model.IsFeaturedProduct;
            productCategory.DisplayOrder      = model.DisplayOrder;
            _categoryService.UpdateProductCategory(productCategory);

            return(new NullJsonResult());
        }
예제 #5
0
        public virtual async Task <IActionResult> ProductUpdate(CategoryProductModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            //try to get a product category with the specified id
            var productCategory = await _categoryService.GetProductCategoryByIdAsync(model.Id)
                                  ?? throw new ArgumentException("No product category mapping found with the specified id");

            //fill entity from product
            productCategory = model.ToEntity(productCategory);
            await _categoryService.UpdateProductCategoryAsync(productCategory);

            return(new NullJsonResult());
        }
        // GET: OptionalItem

        public ActionResult Index()
        {
            if (TempData["itemList"] != null)
            {
                //return Content("some some in temp data itemlist");
                TempData.Keep("itemList");
            }


            if (Session["Customer"] == null)
            {
                return(RedirectToAction("", "Customer"));
            }

            OptionalItemViewModel viewM = new OptionalItemViewModel();


            Dictionary <string, CategoryProductModel> dummy = new Dictionary <string, CategoryProductModel>();

            viewM.CategoryProductModelDic = dummy;
            // loop test
            int?CategoryIdMax = db.Categories.Max(u => (int?)u.CategoryID);

            for (int i = 2; i <= CategoryIdMax; i++)
            {
                // categoryID with 2 digit
                string s = String.Format("categoryId{0}", i.ToString("D2"));

                // select coresponding collections of products, and tolist
                var queryProductDynamic = (from o in db.Products
                                           where o.ProductID > 1 && o.CategoryID == i
                                           select o).ToList();

                CategoryProductModel tempObj = new CategoryProductModel();

                tempObj.CategoryID   = queryProductDynamic[0].CategoryID;
                tempObj.CategoryName = queryProductDynamic[0].Category.CategoryName;
                tempObj.Products     = queryProductDynamic;

                viewM.CategoryProductModelDic[s] = tempObj;
            }

            return(View(viewM));
        }
예제 #7
0
        public ActionResult Index()
        {
            //List<Category> categories = categoryManager.GetAllCategoryEntity().ToList();
            //return View(categories);

            //IList<CategoryProductModel> categoryVM = categoryproductManager.GetCategory().ToList();
            //IList<CategoryProductModel> productVM = categoryproductManager.GetProducts().ToList();

            //List<Category> categoryVM = CategoryProductModel.
            //List<CategoryProductModel> productVm = new List<CategoryProductModel>();

            var viewModel = new CategoryProductModel
            {
                categories = categoryManager.GetAllCategoryEntity().ToList(),
                products   = productManager.GetAllProductsEntity().ToList()
            };

            return(View(viewModel));
        }
        public ActionResult Index()
        {
            TempData["shoppingURL"] = Request.Url.PathAndQuery;

            if (TempData["itemList"] != null)
            {
                TempData.Keep("itemList");
            }


            SingleBuyViewModel viewM = new SingleBuyViewModel();

            Dictionary <string, CategoryProductModel> dummy = new Dictionary <string, CategoryProductModel>();

            viewM.CategoryProductModelDic = dummy;
            // loop
            int?CategoryIdMax = db.Categories.Max(u => (int?)u.CategoryID);

            for (int i = 2; i <= CategoryIdMax; i++)
            {
                // categoryID with 2 digit
                string s = String.Format("categoryId{0}", i.ToString("D2"));

                // select coresponding collections of products, and tolist
                var queryProductDynamic = (from o in db.Products
                                           where o.ProductID > 1 && o.CategoryID == i
                                           select o).ToList();


                CategoryProductModel tempObj = new CategoryProductModel();

                tempObj.CategoryID   = queryProductDynamic[0].CategoryID;
                tempObj.CategoryName = queryProductDynamic[0].Category.CategoryName;
                tempObj.Products     = queryProductDynamic;

                viewM.CategoryProductModelDic[s] = tempObj;
            }

            return(View("Index", "_Layout2", viewM));
        }