public void Add_Test()
        {
            _contr.AddProduct(_pr, 5);

            Assert.IsTrue(Storage.products.ContainsKey(5));
            Assert.AreEqual(Storage.products[5].Name, "The Twisted Ones");
        }
Beispiel #2
0
        public void TestValidDataAddition()
        {
            Thread.Sleep(100);
            var num      = RandomNumberGenerator.GetInt32(100) + 10;
            var testProd = Helper.GetProductDataModelObject(num, "test" + num);

            Assert.True(_productController.AddProduct(testProd) == HttpStatusCode.OK);
            //Clean Up
            _productController.RemoveProduct(testProd.Id);
        }
Beispiel #3
0
        public void ProductController_AddProduct_Success()
        {
            repository.Setup(a => a.AddProduct(addProduct)).Returns(addProduct);
            var response     = controller.AddProduct(addProduct);
            var conNegResult = response as OkNegotiatedContentResult <Product>;

            Assert.IsNotNull(conNegResult);
            Assert.AreEqual(addProduct, conNegResult.Content);
            Assert.IsInstanceOfType(conNegResult.Content, typeof(Product));
            Assert.AreEqual(HttpStatusCode.OK, response.ExecuteAsync(new CancellationToken()).Result.StatusCode);
        }
        public async Task AddProduct_WithValidProduct_ReturnsOK()
        {
            Product toAdd = new Product {
                Name = "ToAdd", Price = 20
            };

            A.CallTo(() => _productsService.AddProduct(toAdd)).Returns(toAdd);
            ActionResult <Product> returns = await _productController.AddProduct(toAdd);

            A.CallTo(() => _productsService.AddProduct(A <Product> ._)).MustHaveHappened();
            Assert.AreEqual(returns.Result.GetType(), typeof(OkObjectResult));
        }
Beispiel #5
0
        public async Task AddProduct_DataAddedSuccessfully()
        {
            //Arrange
            MoqRepositoryClass.Setup(x => x.AddProduct(_product)).Returns(true);

            //Act
            HttpResponseMessage result = await ProductController.AddProduct(_product);

            //Assert
            Assert.IsTrue(result.StatusCode == HttpStatusCode.OK);
            Assert.IsTrue(result.TryGetContentValue(out Product product));
            Assert.AreEqual("Iphone 10", product.Name);
            Assert.AreEqual("This is Iphone 10", product.Description);
        }
Beispiel #6
0
        public void TestAddProductWithLogin()
        {
            string         token      = LoginContext.GetInstance().GenerateNewToken("1");
            UserContextDTO contextDTO = new UserContextDTO();

            contextDTO.UserDTO = new UserDTO();
            contextDTO.UserDTO.Roles.Add(new RoleDTO()
            {
                RoleId = ESportUtils.ADMIN_ROLE
            });
            contextDTO.Token = token;
            LoginContext.GetInstance().SaveContext(contextDTO);
            var mockProductService = new Mock <IProductService>();

            mockProductService.Setup(x => x.AddProduct(new ProductRequest()));
            var controller        = new ProductController(mockProductService.Object);
            var controllerContext = new HttpControllerContext();
            var request           = new HttpRequestMessage();

            request.Headers.Add(ControllerHelper.TOKEN_NAME, token);
            controllerContext.Request    = request;
            controller.ControllerContext = controllerContext;
            IHttpActionResult response = controller.AddProduct(new ProductRequest());
            var contentResult          = response as OkNegotiatedContentResult <ControllerResponse>;

            Assert.IsTrue(contentResult.Content.Success);
        }
        public void GetAllProductsOfStoreByGivenStoreId()
        {
            var data = new List <Product>
            {
                new Product("banan", 1.99, 3, DateTime.Now, 1),
                new Product("chokolad", 3.45, 3, DateTime.Now, 2),
                new Product("kiwi", 4, 1, DateTime.Now, 3),
                new Product("PANDISHPAN", 3.21, 4, DateTime.Now, 1)
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Product> >();

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

            var mockContext = new Mock <FoodStoreContext>();

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

            var service = new ProductController(mockContext.Object);

            data.ToList().ForEach(p => service.AddProduct(p));
            var expected = service.GetAllProducts(1);// banan and pandishpan

            Assert.AreEqual(expected, data.Where(x => x.ProductStoreId == 1).ToList(),
                            "GetALLProducts method doesn't return right products. Check ProductStoreId!");
        }
        private void OnAddProduct()
        {
            if (IsValid())
            {
                MessageBoxResult result = MessageBox.Show(Properties.Resources.WarningMsgBoxEdit, Properties.Resources.WarningMsgBoxTitle, MessageBoxButton.OKCancel);
                switch (result)
                {
                case MessageBoxResult.OK:
                    int r = ProductController.AddProduct(NewProduct);
                    if (r == 201)
                    {
                        MessageBox.Show(Properties.Resources.ProductCreated, Properties.Resources.WarningMsgBoxTitle, MessageBoxButton.OK);
                    }
                    else
                    {
                        MessageBox.Show(Properties.Resources.ErrorMsg, Properties.Resources.WarningMsgBoxTitle, MessageBoxButton.OK);
                    }
                    Back();
                    break;

                case MessageBoxResult.Cancel:
                    break;
                }
            }
        }
        public void GetProductByIdCheck()
        {
            var data = new List <Product>
            {
                new Product("banan", 1.99, 3, DateTime.Now, 1),
                new Product("chokolad", 3.45, 3, DateTime.Now, 2),
                new Product("kiwi", 4, 1, DateTime.Now, 3)
            }.AsQueryable();
            var mockSet = new Mock <DbSet <Product> >();

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

            var mockContext = new Mock <FoodStoreContext>();

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

            var service = new ProductController(mockContext.Object);

            data.ToList().ForEach(p => service.AddProduct(p));
            var expected = service.GetProduct(1); // banan

            Assert.AreEqual(expected, data.FirstOrDefault(x => x.Id == 1),
                            "GetProduct method doesn't return right product. Check id!");
        }
        private void addProduct()
        {
            ProductInfo pro = new ProductInfo();

            pro.title               = txtTitle.Text;
            pro.description         = txtDesciption.Text;
            pro.price               = float.Parse(txtPrice.Text);
            pro.amount              = int.Parse(txtAmount.Text);
            pro.product_category_id = ddlCategory.SelectedValue;
            pro.create_by           = (SessionApp.user_info == null) ? "No Login" : SessionApp.user_info.user_name;
            var result = ProductController.AddProduct(pro);

            if (result == null)
            {
                ShowMessage(Page, "ชื่อสินค้าในหมวดหมู่นี้มีอยู่ในระบบแล้ว");
            }
            else
            {
                foreach (var current in fileImage.PostedFiles)
                {
                    string exttension   = System.IO.Path.GetExtension(current.FileName);
                    string newNameImage = Guid.NewGuid().ToString();
                    current.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"), newNameImage + exttension));
                    listofuploadedfiles.Text += String.Format("{0}<br />", newNameImage + exttension);

                    ProductController.AddProductImage(result.product_id, newNameImage + exttension, result.create_by);
                }
                ShowMessage(Page, "เพิ่มหมวดหมู่สำเร็จ");
            }
        }
        private static void AddProduct(ProductController productController)
        {
            Console.Write("Product Name: ");
            var name = Console.ReadLine();

            Console.Write("Product Price: ");
            var price = double.Parse(Console.ReadLine());

            Console.Write("How much is in stock: ");
            var stock = int.Parse(Console.ReadLine());

            Console.Write("Expiry date (YYYY:MM:DD): ");
            var dateInText = Console.ReadLine()?.Split(':');
            var date       = new DateTime(int.Parse(dateInText?[0]), int.Parse(dateInText?[1]), int.Parse(dateInText?[2]));

            Console.Write("In which store is it (use store id): ");
            var productStoreId = int.Parse(Console.ReadLine());

            var product = new Product(name, price, stock, date, productStoreId);

            try
            {
                productController.AddProduct(product);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Press B to go back");
                var dummy = Console.ReadLine();
            }
        }
Beispiel #12
0
        public void Return_created_when_a_product_is_successfully_added()
        {
            var productController = new ProductController(productRepositoryMock.Object);
            var product           = fixture.Create <Product>();

            var response = productController.AddProduct(product) as StatusCodeResult;

            Assert.That(response.StatusCode, Is.EqualTo(StatusCodes.Status201Created));
        }
Beispiel #13
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            dynamic i = Manufacturedatebox.Value.ToString();
            dynamic j = Expirydatebox.Value.ToString();

            ProductController.AddProduct(Namebox.Text, Batchbox.Text, Quantitybox.Text, Buypricebox.Text, Sellpricebox.Text, i, j, DescriptionBox.Text);
            //dataGridViewUsers.DataSource = EmployeeController.GetAllUsers();
            MessageBox.Show("Successfully Added Product");
            metroGrid.DataSource = ProductController.GetAllProducts();
        }
Beispiel #14
0
        public void TestAddProductWithoutToken()
        {
            var mockProductService = new Mock <IProductService>();

            mockProductService.Setup(x => x.AddProduct(new ProductRequest()));
            var controller             = new ProductController(mockProductService.Object);
            IHttpActionResult response = controller.AddProduct(new ProductRequest());
            var contentResult          = response as OkNegotiatedContentResult <ControllerResponse>;

            Assert.IsNotNull(contentResult.Content.Message);
        }
        private void BtnAddProduct_Click(object sender, EventArgs e)
        {
            decimal unitPrice;
            short   unitsInStock, unitsOnOrder, reorderLevel;
            bool    isUnitPriceValid = Decimal.TryParse(txtUnitPrice.Text, out unitPrice);

            if (!isUnitPriceValid)
            {
                unitPrice = -1;
            }
            bool isUnitsInStockValid = short.TryParse(txtUnitsInStock.Text, out unitsInStock);

            if (!isUnitsInStockValid)
            {
                unitsInStock = -1;
            }
            bool isUnitsOnOrderValid = short.TryParse(txtUnitsOnOrder.Text, out unitsOnOrder);

            if (!isUnitsOnOrderValid)
            {
                unitsOnOrder = -1;
            }
            bool isReorderLevelValid = short.TryParse(txtReorderLevel.Text, out reorderLevel);

            if (!isReorderLevelValid)
            {
                reorderLevel = -1;
            }
            Product product = new Product
            {
                ProductName     = txtProductName.Text,
                SupplierID      = Convert.ToInt32(cmbSuppliers.SelectedValue),
                CategoryID      = Convert.ToInt32(cmbCategories.SelectedValue),
                QuantityPerUnit = txtQuantityPerUnit.Text,
                UnitPrice       = unitPrice,
                UnitsInStock    = unitsInStock,
                UnitsOnOrder    = unitsOnOrder,
                ReorderLevel    = reorderLevel,
                Discontinued    = chckDiscontinued.Checked
            };
            ReturnMessage message = productController.AddProduct(product);

            MessageBox.Show(message.Value);
            if (message.isSuccessful)
            {
                foreach (Control control in Controls)
                {
                    if (control is TextBox)
                    {
                        control.Text = string.Empty;
                    }
                }
            }
        }
        public void AddProduct()
        {
            // Arrange
            ProductController controller = new ProductController(ProductRepository, CategoryRepository);

            // Act
            ViewResult result = controller.AddProduct(prod) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Beispiel #17
0
        public void Delegate_adding_a_product_to_the_repository()
        {
            var productController = new ProductController(productRepositoryMock.Object);
            var product           = fixture.Create <Product>();

            productRepositoryMock.Setup(b => b.Add(It.IsAny <Product>()));

            var response = productController.AddProduct(product) as StatusCodeResult;

            productRepositoryMock.Verify(b => b.Add(It.IsAny <Product>()), Times.Once());
            Assert.That(response.StatusCode, Is.EqualTo(StatusCodes.Status201Created));
        }
Beispiel #18
0
        public void Can_Add_Product()
        {
            Mock <IProductRepository> mock       = new Mock <IProductRepository>();
            Mock <IMapper>            mapperMock = new Mock <IMapper>();

            Product product = new Product("Bike", "Good bike", 199);

            ProductController controller = new ProductController(mock.Object, mapperMock.Object);

            Product result = controller.AddProduct(product);

            Assert.True(result != null);
        }
Beispiel #19
0
        public void AddProduct_ShouldAddProduct()
        {
            var controller = new ProductController(_dbContext);

            Product testProduct = new Product {
                Id = 5, Name = "Demo5", Price = 18.09M
            };

            controller.AddProduct(testProduct);
            Product result = controller.GetProduct(5) as Product;

            Assert.AreEqual(testProduct.Name, result.Name);
        }
        public async Task Create_Product_Successful_Return_Created()
        {
            _mockProductDataAccess.Setup(m => m.AddProduct(It.IsAny <ProductItem>())).ReturnsAsync(true);
            var product = new ProductItem
            {
                ProductId = 777, ProductName = "Cricket Bat", ProductPrice = 1000.99, IsProductAvailable = true
            };

            var result = await _productController.AddProduct(product);

            Assert.NotNull(result);
            Assert.AreEqual((int)HttpStatusCode.Created, ((Microsoft.AspNetCore.Mvc.ObjectResult)result).StatusCode);
        }
        public async Task Add_product_with_all_details_success()
        {
            //Arrange
            _mediatorMock.Setup(m => m.Send(It.IsAny <AddProductCommand>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new Guid());

            //Act
            var productController = new ProductController(_mediatorMock.Object, _productQueriesMock.Object, _loggerMock.Object);
            var actionResult      = await productController.AddProduct(new AddProductCommand("New Product", "Testing", (decimal)10.00));

            //Assert
            Assert.Equal(new Guid(), actionResult.Value);
        }
        public void ExpectToCallDataAccesAddProductOnReceivedPostRequest()
        {
            ProductController controller = new ProductController();

            controller.DataAccess = Substitute.For <IProductDataAccess>();
            Product product = new Product()
            {
                LastUpdated = DateTime.Now, Name = "Test", Price = 2, Photo = null
            };

            controller.AddProduct(product);
            controller.DataAccess.Received().AddProduct(product);
        }
Beispiel #23
0
        public async Task AddProduct()
        {
            var product = A.New <Product>().Adapt <AddProductDto>();

            var mockedService = new Mock <IProductManager>();

            mockedService.Setup(x => x.AddProduct(product)).Returns(Task.FromResult(true));
            var controller = new ProductController(mockedService.Object, _logger);

            var result = await controller.AddProduct(product);

            Assert.AreEqual(result.ErrorState, false);
        }
Beispiel #24
0
        public void CheckIfAddProductWorks()
        {
            //Arrange
            var initialcartSize = Product.GetAllProduct().Count;

            //Act
            Product.AddProduct("Knives", 9);

            var actualSize = Product.GetAllProduct().Count;
            var expected   = initialcartSize + 1;

            //Assert
            Assert.That(expected, Is.EqualTo(actualSize));
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("---------------Management Product---------------");
                Console.WriteLine("1. Add new product.");
                Console.WriteLine("2. Display list product.");
                Console.WriteLine("3. Delete product.");
                Console.WriteLine("4. Exit.");
                Console.WriteLine("------------------------------------------------");
                Console.WriteLine("Please enter your choice");
                var choice = Int16.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Console.WriteLine("Add Product.");
                    if (ProductController.AddProduct())
                    {
                        Console.WriteLine("Add success!!!");
                    }
                    else
                    {
                        Console.WriteLine("Failed. Please try again.");
                    }

                    break;

                case 2:
                    Console.WriteLine("List product.");
                    ProductController.DisplayList();
                    break;

                case 3:
                    if (ProductController.DeleteById())
                    {
                        Console.WriteLine("Deleted success!");
                    }
                    else
                    {
                        Console.WriteLine("Failed. Please try again.");
                    }
                    break;

                case 4:
                    Console.WriteLine("Good bye!!!");
                    Environment.Exit(2);
                    break;
                }
            }
        }
Beispiel #26
0
 private void BtnProductAdd_Click(object sender, EventArgs e)
 {
     Product product = new Product()
     {
         ProductName     = txtProductName.Text,
         QuantityPerUnit = txtQuantity.Text,
         UnitPrice       = Convert.ToDecimal(txtUnitPrice.Text),
         UnitsInStock    = Convert.ToInt16(txtUnitsInStock.Text),
         UnitsOnOrder    = Convert.ToInt16(txtUnitsOnOrder.Text),
         ReorderLevel    = Convert.ToInt16(txtReorderedLevel.Text),
         Discontinued    = checkBoxDiscontinued.Checked
     };
     bool isAdded = productController.AddProduct(product);
 }
Beispiel #27
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(shopId.Text.Trim()) || string.IsNullOrEmpty(name.Text.Trim()) || string.IsNullOrEmpty(price.Text.Trim()) || string.IsNullOrEmpty(shopId.Text.Trim()) || string.IsNullOrEmpty(quantity.Text.Trim()))
     {
         MessageBox.Show("Please give all Information", "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             var product = new
             {
                 Id       = Convert.ToInt32(id.Text.Trim()),
                 Name     = name.Text.Trim(),
                 Quantity = Convert.ToInt32(quantity.Text.Trim()),
                 Price    = Convert.ToInt32(price.Text.Trim()),
                 ShopId   = Convert.ToInt32(shopId.Text.Trim())
             };
             var shopResult = ShopController.GetShop(product.ShopId);
             if (shopResult != null)
             {
                 var Result = ProductController.AddProduct(product);
                 if (Result)
                 {
                     MessageBox.Show("Product Added", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.None);
                     id.Text       = null;
                     name.Text     = null;
                     quantity.Text = String.Format("0");
                     price.Text    = null;
                     shopId.Text   = null;
                     var result = ProductController.GetAllProduct1();
                     dataGridView1.DataSource = result;
                 }
                 else
                 {
                     MessageBox.Show("Product Couldn't added", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("No Shop Found", "Product Registration", MessageBoxButtons.OK, MessageBoxIcon.None);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        public void AddProduct_ReturnsCorrectViewResult()
        {
            // Arrange
            Mock <IProductProvider>  productProviderMock  = new Mock <IProductProvider>();
            Mock <IProductHandler>   productHandlerMock   = new Mock <IProductHandler>();
            Mock <IProductValidator> productValidatorMock = new Mock <IProductValidator>();

            ProductController controller = new ProductController(productProviderMock.Object, productHandlerMock.Object, productValidatorMock.Object);
            // Act
            ViewResult result = controller.AddProduct(null) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("AddProduct", result.ViewName);
        }
Beispiel #29
0
        public void AddProduct()
        {
            int     count   = productController.GetProducts().Count;
            Product product = new Product()
            {
                Name       = "Product1",
                Descrption = "Product added"
            };

            productController.AddProduct(product);
            int newCount = productController.GetProducts().Count;

            Assert.That(newCount == count + 1);
            //Assert.AreEqual("Product1", product.Name);
        }
Beispiel #30
0
        public void Test_AddProduct()
        {
            var saveproduct = new SaveProductResource
            {
                Description = "testAdd"
            };
            var product = Mapper.Map <Product>(saveproduct);

            product.Id = GetProductData().ToList().Max(i => i.Id) + 1;
            _mockService.Setup(x => x.AddProduct(product)).Returns(product);

            var actual = _sut.AddProduct(saveproduct);

            Assert.IsNull(actual);
        }
Beispiel #31
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    PortalSecurity security = new PortalSecurity();

                    ProductInfo product = new ProductInfo();
                    product = ((ProductInfo)CBO.InitializeObject(product, typeof(ProductInfo)));

                    product.ProductID		= _nav.ProductID;
                    product.PortalID		= this.PortalId;
                    product.Manufacturer    = ""; // security.InputFilter(txtManufacturer.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.MultiLine);
                    product.ModelName		= security.InputFilter(txtModelName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.MultiLine);
                    product.ModelNumber		= security.InputFilter(txtModelNumber.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.MultiLine);
                    //product.Summary			= security.InputFilter(txtSummary.Text, PortalSecurity.FilterFlag.MultiLine);
                    product.Summary         = security.InputFilter(txtSummary.Text, PortalSecurity.FilterFlag.NoScripting);
                    product.UnitCost		= Decimal.Parse(txtUnitPrice.Text);
                    product.PriceStr        = tbPriceStr.Text;
                    //product.ProductImage	= GetImageUrl(image1);
                    product.CategoryID      = 4; // int.Parse(cmbCategory.SelectedValue);
                    product.Archived		= chkArchived.Checked;
                    product.Featured        = false;  // chkFeatured.Checked;
                    product.Description     = security.InputFilter(txtDescription.Text, PortalSecurity.FilterFlag.NoScripting);
                    product.DescriptionTwo  = security.InputFilter(txtDescriptionTwo.Text, PortalSecurity.FilterFlag.NoScripting);
                    product.DescriptionThree = security.InputFilter(txtDescriptionThree.Text, PortalSecurity.FilterFlag.NoScripting);
                    product.CreatedByUser = this.UserId.ToString();
                    product.CreatedDate		= DateTime.Now;
                    product.ProductWeight   = 0; //txtUnitWeight.Text.Length > 0 ? Decimal.Parse(txtUnitWeight.Text) : -1;
                    product.ProductHeight   = 0; //txtUnitHeight.Text.Length > 0 ? Decimal.Parse(txtUnitHeight.Text) : -1;
                    product.ProductLength   = 0; //txtUnitLength.Text.Length > 0 ? Decimal.Parse(txtUnitLength.Text) : -1;
                    product.ProductWidth    = 0; //txtUnitWidth.Text.Length > 0 ? Decimal.Parse(txtUnitWidth.Text) : -1;
                    product.SaleStartDate   = calSaleStartDate.SelectedDate != Null.NullDate ? calSaleStartDate.SelectedDate : DateTime.Parse("01/01/9999");
                    product.SaleEndDate     = calSaleEndDate.SelectedDate != Null.NullDate ? calSaleEndDate.SelectedDate : DateTime.Parse("01/01/9999");
                    product.SalePrice       = txtSalePrice.Text.Length > 0 ? Decimal.Parse(txtSalePrice.Text) : -1;

                    // canadean changed: added new parameters
                    product.CategoryID1 = int.Parse(cmbCategory1.SelectedValue);
                    product.CategoryID2 = int.Parse(cmbCategory2.SelectedValue);
                    product.CategoryID3 = int.Parse(cmbCategory3.SelectedValue);
                    product.NumPages = txtNumPages.Text.Length > 0 ? int.Parse(txtNumPages.Text) : -1;
                    ///product.PublishDate = calPublishDate.SelectedDate != Null.NullDate ? calPublishDate.SelectedDate : DateTime.Parse("01/01/9999");

                    CultureInfo ukCulture = new CultureInfo("en-GB");
                    product.PublishDate = tbPublishDate.Text != "" ? DateTime.Parse(tbPublishDate.Text, ukCulture.DateTimeFormat) : DateTime.Parse("01/01/9999");
                    //product.DeliveryMethod = txtDeliveryMethod.Text.Length > 0 ? int.Parse(txtDeliveryMethod.Text) : -1;
                    product.DeliveryMethod = int.Parse(cmbDeliveryMethod.SelectedValue);
                    //product.AvailableOnline = true; // chkAvailableOnline.Checked;
                    product.AvailableOnline = chkAvailableOnline.Checked;
                    //product.ProductImage2 = GetImageUrl(image2);
                    //product.ProductImage3 = GetImageUrl(image3);
                    product.DescriptionTag = tbDescriptionTag.Text;
                    product.TOC_Html = txtTOC_Html.Text;

                    product.ProductFile = GetImageUrl(file1);
                    product.ProductPreview = GetImageUrl(preview1);

                    //product.ProductFile = tbFile1.Text;
                    //product.ProductPreview = tbPreview1.Text;

                    calSaleStartDate.SelectedDate = product.SaleStartDate == Null.NullDate ? Null.NullDate : product.SaleStartDate;
                    calSaleEndDate.SelectedDate = product.SaleEndDate == Null.NullDate ? Null.NullDate : product.SaleEndDate;
                    txtSalePrice.Text = product.SalePrice == Null.NullDecimal ? string.Empty : product.SalePrice.ToString("0.00");

                    ProductController controller = new ProductController();
                    if (Null.IsNull(product.ProductID))
                    {
                        controller.AddProduct(product);
                    }
                    else
                    {
                        // Ajouté pour contourner le bug System.NullReferenceException
                        if (product.ProductImage.StartsWith("http:///"))
                        {
                            product.ProductImage = product.ProductImage.Replace("http://", "");
                        }
                        if (product.ProductImage2.StartsWith("http:///"))
                        {
                            product.ProductImage2 = product.ProductImage2.Replace("http://", "");
                        }
                        if (product.ProductImage3.StartsWith("http:///"))
                        {
                            product.ProductImage3 = product.ProductImage3.Replace("http://", "");
                        }
                        if (product.ProductFile.StartsWith("http:///"))
                        {
                            product.ProductFile = product.ProductFile.Replace("http://", "");
                        }
                        if (product.ProductPreview.StartsWith("http:///"))
                        {
                            product.ProductPreview = product.ProductPreview.Replace("http://", "");
                        }

                        controller.UpdateProduct(product);
                    }

                    invokeEditComplete();
                }
            }
            catch(Exception ex)
            {
                Response.Write(ex.Message);
                Response.Write(ex.StackTrace);

                //Exceptions.ProcessModuleLoadException(this, ex);
            }
        }