You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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)
andprotected 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.
The text was updated successfully, but these errors were encountered: