コード例 #1
0
        protected void btnDel_Click(object sender, EventArgs e)
        {
            bool Del = false;

            for (int i = 0; i < grData.Rows.Count; i++)
            {
                try
                {
                    HtmlInputCheckBox htmlCheckBox = (HtmlInputCheckBox)grData.Rows[i].FindControl("cbxDel");
                    if (htmlCheckBox.Checked)
                    {
                        ProductsManager.Delete(int.Parse(htmlCheckBox.Value));
                        Del = true;
                    }
                }
                catch { }
            }
            BindData();
            if (Del)
            {
                this.lblError.Text = "Đã xóa bài viết.";
            }
            else
            {
                this.lblError.Text = "Không có bài viết nào bị xóa.";
            }
        }
コード例 #2
0
        public JsonResult Delete([FromQuery] Guid id)
        {
            _productsManager.Delete(id);

            return(Json(new JsonResponse {
                Code = ResponseCodes.Ok
            }));
        }
コード例 #3
0
        public string Delete(int id)
        {
            var productName = "";

            using (var productsManager = new ProductsManager())
            {
                productName = productsManager.Get(id).Name;
                productsManager.Delete(id);
            }
            return(string.Format("Product '{0}' successfully deleted!", productName));
        }
コード例 #4
0
        public void DeleteAnProductWithElements()
        {
            var product = products.ElementAt(2);

            //Act

            var productManager = new ProductsManager(dataServiceMock.Object, categorySelected);

            Assert.ThrowsException <Exception>(() => productManager.Delete(product));
            dataServiceMock.Verify(m => m.Delete(product), Times.Never());
        }
コード例 #5
0
        public void DeleteAnProductWithoutProducts()
        {
            var product = new Product()
            {
                Name = "Mantequilla"
            };


            //Act
            var productManager = new ProductsManager(dataServiceMock.Object, categorySelected);

            productManager.Delete(product);

            // Asserts
            var productExpected = productManager.Products.Where(p => p.Name == product.Name)
                                  .FirstOrDefault();

            Assert.IsNull(productExpected);
            Assert.AreEqual(2, productManager.Products.Count);
            dataServiceMock.Verify(m => m.Delete(product));
        }