Repository navigation
Split ProductViewModelService into one service per product tab - #975
Merged
KrzysztofPajak merged 30 commits intoOct 22, 2026
Merged
Conversation
added 28 commits
October 21, 2026 22:25
…o their own services
The stock total now includes a newly added combination, a multi-warehouse update sums reserved quantity as the insert does, and saving a combination that no longer exists returns a warning.
The product tab controllers no longer depend on the product view-model service. Also corrects the scope comments left behind by the split.
…e-product-controller
InsertAsync stamps CreatedOnUtc with the current time, so the dates the test gave were dropped and posts inserted in the same millisecond came back in any order.
Base automatically changed from
refactor/split-base-product-controller
to
develop
October 22, 2026 17:38
…duct-view-model-service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the architecture backlog (item S5: god classes,
ProductViewModelService)Type: feature
Stacked on #974. Its base is
refactor/split-base-product-controller, so the diff shows only this split; it is retargeted todeveloponce #974 is merged.Issue
Grand.Web.AdminShared/Services/ProductViewModelService.cswas 2712 lines behind an 87-memberIProductViewModelService, with 39 constructor dependencies. After #974 split the product edit tabs into their own controllers, each of those controllers still depended on the whole service and on everything it injects.Solution
One
IProduct<Tab>ViewModelService/Product<Tab>ViewModelServiceper tab controller, registered as scoped next toIProductViewModelService, the same lifetime as before. Each takes only the services its members use:ProductSpecificationProductPictureProductCategoryProductCollectionProductBidProductPricePrepareTierPriceModeloverloads)ProductRelatedProductBundleProductAssociatedProductAttributeMappingProductAttributeCombinationOutOfStockNotifications)ProductAddPopupPrepareAddRequiredProductModel,Prepare{Related,Similar,Bundle,CrossSell,Recommended,Associated}ProductModel,PrepareAssociateProductToAttributeValueModel) and its product searchPrepareProductModel(AddProductModel, ...)Members moved unchanged, with their comments, except for the combination stock fix below.
ProductViewModelServicekeeps the product form (prepare, insert, update, delete, warehouse inventory, tags, picture SEO names, out-of-stock notification for the product), the list and search, reviews and bulk edit.The tab controllers take their new service and no longer depend on
IProductViewModelService; the popup actions takeIProductAddPopupViewModelService.Attribute combinations (
ProductAttributeCombinationViewModelService): the product's stock total is now computed on the product already loaded, so it includes a combination added in the same request (it did not before); a multi-warehouse update now sums the reserved quantity as the insert already did; saving a combination that no longer exists returns a warning instead of throwing.Tests: the controller tests set up the new mocks for the moved members, and nothing else in them changed. The service tests of moved members are in
ProductPriceViewModelServiceTests,ProductRelatedViewModelServiceTests,ProductBundleViewModelServiceTestsandProductAddPopupViewModelServiceTests, each with a fixture that builds only that service;ProductAttributeCombinationViewModelServiceTestscovers the stock fix.ProductViewModelServiceTestslost the arguments the trimmed constructor no longer takes.Breaking changes
IProductViewModelServiceto the new interfaces. Code outside this repository that calls one of them onIProductViewModelServicemust inject the matchingIProduct<Tab>ViewModelServiceorIProductAddPopupViewModelService.IProductViewModelService, or subclassesProductViewModelServiceand overrides a moved virtual, must move that code to the new service. TheProductViewModelServiceconstructor lost the parameters only the moved members used.Testing
dotnet build GrandNode.slnx: no errors.dotnet testforGrand.Web.Admin.Tests(1596),Grand.Web.Store.Tests(181) andGrand.Web.Vendor.Tests(53) pass. No assertion was removed or weakened.