コード例 #1
0
        /// <summary>
        /// Disables a Product.
        /// </summary>
        /// <param name="deleteProductMV">DeleteProductModelView with the Product data being disabled.</param>
        /// <exception cref="ResourceNotFoundException">Thrown when the Product is not found.</exception>
        public void disableProduct(DeleteProductModelView deleteProductMV)
        {
            ProductRepository productRepository    = PersistenceContext.repositories().createProductRepository();
            Product           productBeingDisabled = productRepository.find(deleteProductMV.productId);

            if (productBeingDisabled == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_PRODUCT_BY_ID, deleteProductMV.productId));
            }

            productRepository.remove(productBeingDisabled);
        }
コード例 #2
0
        public ActionResult disableProduct(long id)
        {
            DeleteProductModelView deleteProductMV = new DeleteProductModelView();

            deleteProductMV.productId = id;
            try {
                new core.application.ProductController().disableProduct(deleteProductMV);
                return(NoContent());
            } catch (ResourceNotFoundException e) {
                return(NotFound(new SimpleJSONMessageService(e.Message)));
            } catch (Exception) {
                return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR)));
            }
        }