Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ProductReview infrastructure to a dedicated service #7392

Open
danFbach opened this issue Oct 28, 2024 · 0 comments
Open

Migrate ProductReview infrastructure to a dedicated service #7392

danFbach opened this issue Oct 28, 2024 · 0 comments

Comments

@danFbach
Copy link
Contributor

I'm am trying to build a plugin that would make product reviews a bit more modular - so that they can be added/viewed in more than just the dedicated reviews page. A dedicated reviews page is poor UX in my opinion. I'm planning to inline reviews on the product page itself.

There is a a lot of code related to product reviews contained within the ProductController, which, in my opinion, should be migrated to a dedicated service.

For example, most of what is contained in:
public virtual async Task<IActionResult> ProductReviewsAdd(int productId, ProductReviewsModel model, bool captchaValid)
should be moved to a service function, so that it can be called by a plugin. (especially what is inside of if (ModelState.IsValid) in that action)

Additionally,
protected virtual async Task ValidateProductReviewAvailabilityAsync(Product product) and
protected virtual async ValueTask<bool> HasCompletedOrdersAsync(Product product)
have no reason to be in the product controller, and should exist in a dedicated ProductReviewService.

I understand that for ease of development (with modifying the ModelState) why they were probably contained in the controller initially, but this could certainly be handled by passing back errors from the service and then handling them in the calling function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants