Пример #1
0
        public static Dictionary<string, int> getCategoriesDictionary()
        {
            ProductRepository _p_repo = new ProductRepository();
            IQueryable<Category> categ_list = _p_repo.getAllCategories();
            Dictionary<string, int> dictionary = new Dictionary<string, int>();

            foreach (var item in categ_list)
            {
                dictionary.Add(item.Name, 0);
            }

            return dictionary;
        }
        public ProductWrapper(Models.Product product)
        {
            this.product = product;
            ProductRepository productRepo = new ProductRepository();
            var list = productRepo.getAllCategories().ToList();
            var list2 = new List<String>();

            foreach (Category c in list)
            {
                list2.Add(c.Name);
            }

            categories = new SelectList(list2, product.Category);
        }