예제 #1
0
 public ActionResult DeleteProduct(string ShopId, string ProductId, int Quantity)
 {
     if (_shopService.DeleteProduct(ShopId, ProductId, Quantity))
     {
         return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK));
     }
     return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
 }
예제 #2
0
 public ActionResult DeleteProduct(int id)
 {
     if (shopService.DeleteProduct(id))
     {
         return(Json(id));
     }
     else
     {
         return(Json(false));
     }
 }
예제 #3
0
 public IActionResult DeleteProduct(int id)
 {
     if (shopService.DeleteProduct(id))
     {
         return(Ok(id));
     }
     else
     {
         return(StatusCode(500));
     }
 }
예제 #4
0
        private void BtnProductDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Product productToDelete = (Product)lstProducts.SelectedItem;

                _shopService.DeleteProduct(productToDelete);

                FillProductListBox();
                ClearInputControls();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fout!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void DeleteProduct_WhenNoProductIsSelected_ShouldThrowException()
        {
            // Arrange
            Product     productToDelete = null;
            ShopService shopService     = new ShopService();

            try
            {
                // Act
                shopService.DeleteProduct(productToDelete);
            }
            catch (Exception ex)
            {
                // Assert
                StringAssert.Contains(ex.Message, ShopService.NoProductSelectedToDeleteMessage);
                return;
            }

            Assert.Fail("No exeption was thrown");
        }
        public void DeleteProduct_WithValidProduct_ShouldUpdateProductsList()
        {
            // Arrange
            ShopService shopService = new ShopService();

            for (int i = 0; i < 5; i++)
            {
                shopService.AddNewProduct($"test{i}", new Category("Test"), "100");
            }

            Product productToDelete = shopService.ProductsInShop[1];
            int     expected        = shopService.ProductsInShop.Count - 1;

            // Act
            shopService.DeleteProduct(productToDelete);

            // Assert
            int actual = shopService.ProductsInShop.Count;

            Assert.AreEqual(expected, actual, "Productlist has not been updated!");
        }