public void Delete(int productId) { var dbProduct = productRepository .GetById(productId); if (dbProduct == null) { throw new ValidatorException("Unkonwn product"); } var dbProductCategories = productCategoryRepository .GetByProductId(productId) .ToList(); productCategoryRepository.DeleteCategories(dbProductCategories); productRepository.Delete(dbProduct); }