Esempio n. 1
0
        protected void gvLbDelete_Command(object sender, CommandEventArgs e)
        {
            string response   = "";
            string dependency = "Orderitems#OrderitemId#ProductId#Products Entry - Products|Discount#DiscountId#ProductId#Products Entry - Products";
            string msg        = commonFunction.MasterDependency(Convert.ToInt32(e.CommandName), dependency);

            if (msg == "")
            {
                response = productServices.DeleteProduct(Convert.ToInt32(e.CommandName));
                if (response == "Success")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Success','Product is deleted.')", true);
                    Clear();
                    BindProductsGv();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Error!','" + response + "')", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Error!','" + msg + "')", true);
            }
        }
Esempio n. 2
0
        public bool DeleteProduct(int productId)
        {
            if (productServices.DeleteProduct(productId))
            {
                return(true);
            }

            return(false);
        }
 public IActionResult DeleteProduct(Product product)
 {
     try
     {
         _productServices.DeleteProduct(product);
         return(CreatedAtAction("DeleteProduct", product));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Esempio n. 4
0
 public IActionResult DeleteProduct(Guid id)
 {
     try
     {
         _productServices.DeleteProduct(id);
         return(Ok());
     }
     catch (ArgumentException)
     {
         return(NotFound());
     }
 }
Esempio n. 5
0
        public void DeleteproductTestNegative(string id)
        {
            var cache        = new MemoryCache(new Mock <MemoryCacheOptions>().Object);
            var cacheManager = new CacheManager(cache, options);
            var services     = new ProductServices(cacheManager);

            services.AddProduct(_products);

            var sut = services.DeleteProduct(id);

            sut.Should().NotBeNull();
            sut.IsSuccess.Should().Be(false);
            sut.Error.Should().NotBeNullOrWhiteSpace();
        }
Esempio n. 6
0
        public void DeleteproductTestPositive(string id)
        {
            var cache        = new MemoryCache(new Mock <MemoryCacheOptions>().Object);
            var cacheManager = new CacheManager(cache, options);
            var services     = new ProductServices(cacheManager);

            services.AddProduct(_products);

            var sut = services.DeleteProduct(id);

            sut.Should().NotBeNull();
            sut.IsSuccess.Should().Be(true);
            sut.Value.Count().Should().Be(_products.Count - 1);
        }
Esempio n. 7
0
        public HttpResponseMessage DeleteProduct(int productID)
        {
            var deletedProduct = ProductServices.DeleteProduct(productID);

            var response = Request.CreateResponse(HttpStatusCode.OK, deletedProduct, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("Response-Type", "JSON");

            if (deletedProduct == null)
            {
                var notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound, "(404) Product not found",
                                                              Configuration.Formatters.JsonFormatter);

                notFoundResponse.Headers.Add("API-Version", apiVersion);

                return(notFoundResponse);
            }
            else
            {
                return(response);
            }
        }
Esempio n. 8
0
 public ActionResult DeleteProduct(int id)
 {
     productServices.DeleteProduct(id);
     return(RedirectToAction("Index"));
 }
 public ActionResult Delete(int ID)
 {
     productService.DeleteProduct(ID);
     return(RedirectToAction("ProductTable"));
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     productsServices.DeleteProduct(selectedProduct);
     FillProductsDataGridView();
     FillProductsComboBox();
 }