Exemplo n.º 1
0
        public IEnumerable <Category> getProductByCategory(int parentId)
        {
            List <Category> result = new List <Category>();

            result.Add(_businessCategory.GetById(parentId));
            var children = _businessCategory.GetAll().Where(i => i.ParentId == parentId).ToList();

            foreach (var item in children)
            {
                result.AddRange(getProductByCategory(item.Id));
            }

            return(result);
        }
Exemplo n.º 2
0
        public void GetAllCategories_ReturnsACorrectListOfCategories()
        {
            // Arrange
            var categories = new List <Category>
            {
                new Category {
                    Name = "TestCategory1", Id = 1
                },
                new Category {
                    Name = "TestCategory2", Id = 2
                }
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Category> >();

            mockSet.As <IQueryable <Category> >().Setup(m => m.Provider).Returns(categories.Provider);
            mockSet.As <IQueryable <Category> >().Setup(m => m.Expression).Returns(categories.Expression);
            mockSet.As <IQueryable <Category> >().Setup(m => m.ElementType).Returns(categories.ElementType);
            mockSet.As <IQueryable <Category> >().Setup(m => m.GetEnumerator()).Returns(categories.GetEnumerator());

            var mockContext = new Mock <EazyCartContext>();

            mockContext.Setup(c => c.Categories).Returns(mockSet.Object);

            var categoryBusiness = new CategoryBusiness(mockContext.Object);

            // Act
            var allCategories = categoryBusiness.GetAll();

            // Assert
            Assert.AreEqual(1, allCategories[0].Id, "First Ids do not match.");
            Assert.AreEqual(2, allCategories[1].Id, "Second Ids do not match.");
        }
        private void ProductSettingForm_Load(object sender, EventArgs e)
        {
            cmbStatus.Items.Add("True");
            cmbStatus.Items.Add("False");
            txtProductID.Visible      = false;
            dgvProductList.DataSource = pb.Products();

            cmbCategoryName.BindCombobox <Category>("CategoryName", "CategoryId", (cb.GetAll()));

            cmbCategoryName.DataSource = cb.GetCategory();
        }
Exemplo n.º 4
0
        private void ProductMenu_Load(object sender, EventArgs e)
        {
            txtID.Visible = false;
            Addition isvalidadition = ab.GetByTableId(_tablesForm.SelectedTable.TableID);

            //var deger = pb.Products();
            //foreach (var item in deger)
            //{
            //	lstProduct.Items.Add(item.ProductName);

            //}
            if (isvalidadition != null)
            {
                lblTotalAdditions.Text = isvalidadition.TotalPrice.ToString();
            }
            lblMasaNo.Text = string.Format("{0} Nolu Masa Şiparişleri", _tablesForm.SelectedTable.TableID);
            cmbCategories.Items.Add("Seçiniz..");
            cmbCategories.BindCombobox <Category>("CategoryName", "CategoryId", (cb.GetAll()));
            cmbCategories.DataSource = cb.GetCategory();
        }
Exemplo n.º 5
0
 private void LoadCategory()
 {
     cbCategory.DataSource = objCategoryBusiness.GetAll();
     cbCategory.Refresh();
 }
Exemplo n.º 6
0
 public async Task <List <Category> > GetCategory(string categoryname)
 {
     return(categoryBusiness.GetAll(x => x.CategoryName == categoryname).ToList());
 }
Exemplo n.º 7
0
 private void LoadGrid()
 {
     dgCategory.DataSource = objCategoryBusiness.GetAll();
     dgCategory.Refresh();
 }