Пример #1
0
    public void product_type_service_should_add_item_to_the_underlying_repository()
    {
        var productTypeService = new ProductTypeService(_unitOfWorkMock.Object);
        var productType        = new ProductType {
            Id = 10
        };

        productTypeService.AddProductType(productType);
        _productTypeRepositoryMock.Verify(r => r.Add(It.Is <ProductType>(p => p.Id == productType.Id)), Times.Once());
    }
        public void AddProductType()
        {
            //List<ProductType> list = (List<ProductType>)BaoHienRepository.SelectAll<ProductType>().Where<ProductType>(item => item.st == false).ToList<ProductType>();
            //int count = list.Count;
            ProductType productType = new ProductType
            {
                Description = "P Type 1",
                ProductName = "Product 1",
                TypeCode = "Type code 1"
            };
            ProductTypeService productTypeService = new ProductTypeService();
            bool result = productTypeService.AddProductType(productType);

            Assert.AreEqual<bool>(true, result); ;
        }
Пример #3
0
        public void AddProductType()
        {
            //List<ProductType> list = (List<ProductType>)BaoHienRepository.SelectAll<ProductType>().Where<ProductType>(item => item.st == false).ToList<ProductType>();
            //int count = list.Count;
            ProductType productType = new ProductType
            {
                Description = "P Type 1",
                ProductName = "Product 1",
                TypeCode    = "Type code 1"
            };
            ProductTypeService productTypeService = new ProductTypeService();
            bool result = productTypeService.AddProductType(productType);

            Assert.AreEqual <bool>(true, result);;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validator1.Validate())
            {
                if (productType != null && productType.Id > 0)//edit
                {
                    productType.Description = txtDescription.Text;
                    productType.TypeName = txtName.Text;
                    productType.TypeCode = txtCode.Text;

                    ProductTypeService productTypeService = new ProductTypeService();
                    bool result = productTypeService.UpdateProductType(productType);
                    if (result)
                    {
                        MessageBox.Show("Loại sản phẩm đã được cập nhật vào hệ thống");
                        ((ucProductType)this.CallFromUserControll).loadProductTypeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else//add new
                {
                    productType = new ProductType
                    {

                        Description = txtDescription.Text,
                        TypeName = txtName.Text,
                        TypeCode = txtCode.Text
                    };
                    ProductTypeService productTypeService = new ProductTypeService();
                    bool result = productTypeService.AddProductType(productType);
                    if (result)
                    {
                        MessageBox.Show("Loại sản phẩm đã được thêm mới vào hệ thống");
                        ((ucProductType)this.CallFromUserControll).loadProductTypeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validator1.Validate())
            {
                if (productType != null && productType.Id > 0)//edit
                {
                    productType.Description = txtDescription.Text;
                    productType.TypeName    = txtName.Text;
                    productType.TypeCode    = txtCode.Text;

                    ProductTypeService productTypeService = new ProductTypeService();
                    bool result = productTypeService.UpdateProductType(productType);
                    if (result)
                    {
                        MessageBox.Show("Loại sản phẩm đã được cập nhật vào hệ thống");
                        ((ucProductType)this.CallFromUserControll).loadProductTypeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else//add new
                {
                    productType = new ProductType
                    {
                        Description = txtDescription.Text,
                        TypeName    = txtName.Text,
                        TypeCode    = txtCode.Text
                    };
                    ProductTypeService productTypeService = new ProductTypeService();
                    bool result = productTypeService.AddProductType(productType);
                    if (result)
                    {
                        MessageBox.Show("Loại sản phẩm đã được thêm mới vào hệ thống");
                        ((ucProductType)this.CallFromUserControll).loadProductTypeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }