public void Run() { var productId = Guid.Parse("287278A8-AA52-4B34-A96F-5C94967F3C58");//replace with an actual product Id from the database var deleteProductCommand = new DeleteProductCommand() { Id = productId }; _productService.Delete(deleteProductCommand); }
public void Delete(DeleteProductCommand command) { using (_unitOfWork) { var product = _productRepository.GetById(command.Id); product.Delete(); _productRepository.Update(product); var productReviews = _productReviewRepository.GetByProductId(product.Id); foreach (var productReview in productReviews) { productReview.Delete(); _productReviewRepository.Update(productReview); } _unitOfWork.Commit(); } }