Ejemplo n.º 1
0
        public IActionResult DeleteProduct(int productId)
        {
            var productFromRepo = _supermarketRepository.GetProductById(productId);

            if (productFromRepo == null)
            {
                return(NotFound());
            }

            _supermarketRepository.DeleteProduct(productFromRepo);

            if (!_supermarketRepository.Save())
            {
                throw new Exception($"Deleting product {productId} failed on save.");
            }

            return(NoContent());
        }