/// <summary>
        /// Deletes an instance of Restriction from a Product's Material.
        /// </summary>
        /// <param name="deleteRestrictionFromProductMaterialMV">DeleteRestrictionFromProductMaterialModelView containing the Product's, the Materials's and the Restriction's persistence identifiers.</param>
        /// <exception cref="ResourceNotFoundException">Thrown when the Product, the Material or the Restriction could not be found.</exception>
        public void deleteRestrictionFromProductMaterial(DeleteProductMaterialRestrictionModelView deleteRestrictionFromProductMaterialMV)
        {
            ProductRepository productRepository = PersistenceContext.repositories().createProductRepository();

            Product product = productRepository.find(deleteRestrictionFromProductMaterialMV.productId);

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

            ProductMaterial productMaterial = product.productMaterials.
                                              Where(pm => pm.materialId == deleteRestrictionFromProductMaterialMV.materialId).SingleOrDefault();

            if (productMaterial == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_MATERIAL_BY_ID, deleteRestrictionFromProductMaterialMV.materialId));
            }

            Restriction restriction = productMaterial.restrictions.Where(r => r.Id == deleteRestrictionFromProductMaterialMV.restrictionId).SingleOrDefault();

            if (restriction == null)
            {
                throw new ResourceNotFoundException(string.Format(ERROR_UNABLE_TO_FIND_RESTRICTION_BY_ID, deleteRestrictionFromProductMaterialMV.restrictionId));
            }

            productMaterial.restrictions.Remove(restriction);

            product = productRepository.update(product);
        }
        public ActionResult deleteRestrictionFromProductMaterial(long productId, long materialId, long restrictionId)
        {
            DeleteProductMaterialRestrictionModelView deleteRestrictionFromProductMaterialMV = new DeleteProductMaterialRestrictionModelView();

            deleteRestrictionFromProductMaterialMV.productId     = productId;
            deleteRestrictionFromProductMaterialMV.materialId    = materialId;
            deleteRestrictionFromProductMaterialMV.restrictionId = restrictionId;
            try {
                new core.application.ProductController().deleteRestrictionFromProductMaterial(deleteRestrictionFromProductMaterialMV);
                return(NoContent());
            } catch (ResourceNotFoundException e) {
                return(NotFound(new SimpleJSONMessageService(e.Message)));
            } catch (Exception) {
                return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR)));
            }
        }