public void DeleteProduct(int id) { try { var orderDetails = _orderDetailsRepository.Get().Where(x => x.ProductId == id); foreach (var detail in orderDetails) { _orderDetailsRepository.Delete(detail.OrderId, id); } _productsRepository.Delete(id); } catch (Exception e) { Log.Error("Product service error!" + Environment.NewLine + $"{e}"); throw; } }