public List <ProductCategoryBase> GetAllProductProducer(string culture)
        {
            var comm = this.GetCommand("sp_ProductProducerGetAll");

            comm.AddParameter <string>(this.Factory, "Culture", culture);
            if (comm == null)
            {
                return(null);
            }
            var dt            = this.GetTable(comm);
            var listGroupNews = EntityBase.ParseListFromTable <ProductCategory>(dt);

            try
            {
                var toGroupNewsTree     = ProductCategoryExtensions.ToCategoryTree(GetProductCategoryBaseList(listGroupNews));
                var toFlatGroupNewsTree = ProductCategoryExtensions.ToFlatCategoryTree(toGroupNewsTree);
                return(toFlatGroupNewsTree);
            }
            catch (Exception)
            {
                //throw;
            }
            return(null);
            //throw new NotImplementedException();
        }
Exemplo n.º 2
0
        public void Mains_Should_Throw_ArgumentNullException_If_ProductCategories_Is_Null()
        {
            IQueryable <ProductCategory> productCategories = null;

            var ex = Assert.Throws <ArgumentNullException>(() => ProductCategoryExtensions.Mains(productCategories));

            Assert.Equal(nameof(productCategories), ex.ParamName);
        }
Exemplo n.º 3
0
        public void ProductsByCategory_Should_Throw_ArgumentNullException_If_ProductCategories_Is_Null()
        {
            IQueryable <ProductCategory> productCategories = null;
            Guid categoryId = Guid.NewGuid();

            var ex = Assert.Throws <ArgumentNullException>(() => ProductCategoryExtensions.ProductsByCategory(productCategories, categoryId));

            Assert.Equal(nameof(productCategories), ex.ParamName);
        }
Exemplo n.º 4
0
        public void Mains_Should_Return_Only_Categories_Set_As_Main_Category()
        {
            IQueryable <ProductCategory> productCategories = new ProductCategory[]
            {
                new ProductCategory {
                    CategoryId = Guid.NewGuid(), ProductId = Guid.NewGuid(), IsMain = true
                },
                new ProductCategory {
                    CategoryId = Guid.NewGuid(), ProductId = Guid.NewGuid(), IsMain = true
                },
                new ProductCategory {
                    CategoryId = Guid.NewGuid(), ProductId = Guid.NewGuid(), IsMain = false
                }
            }.AsQueryable();

            var mainCategories = ProductCategoryExtensions.Mains(productCategories).ToArray();

            Assert.True(mainCategories.All(c => c.IsMain));
        }
Exemplo n.º 5
0
        public void ProductsByCategory_Should_Throw_ArgumentException_If_CategoryId_Is_Empty()
        {
            IQueryable <ProductCategory> productCategories = new ProductCategory[]
            {
                new ProductCategory {
                    ProductId = Guid.NewGuid(), CategoryId = Guid.NewGuid()
                },
                new ProductCategory {
                    ProductId = Guid.NewGuid(), CategoryId = Guid.NewGuid()
                },
                new ProductCategory {
                    ProductId = Guid.NewGuid(), CategoryId = Guid.NewGuid()
                }
            }.AsQueryable();
            Guid categoryId = Guid.Empty;

            var ex = Assert.Throws <ArgumentException>(() => ProductCategoryExtensions.ProductsByCategory(productCategories, categoryId));

            Assert.Equal(nameof(categoryId), ex.ParamName);
        }
Exemplo n.º 6
0
        public void ProductsByCategory_Should_Return_Only_ProductCategories_With_The_Specified_Category()
        {
            Guid categoryId = Guid.NewGuid();

            IQueryable <ProductCategory> productCategories = new ProductCategory[]
            {
                new ProductCategory {
                    ProductId = Guid.NewGuid(), CategoryId = categoryId
                },
                new ProductCategory {
                    ProductId = Guid.NewGuid(), CategoryId = categoryId
                },
                new ProductCategory {
                    ProductId = Guid.NewGuid(), CategoryId = Guid.NewGuid()
                }
            }.AsQueryable();

            var productCategoriesByCategory = ProductCategoryExtensions.ProductsByCategory(productCategories, categoryId).ToArray();

            Assert.True(productCategoriesByCategory.Length == 2);
        }