protected override DriverResult Editor(InventoryBySKUSiteSettingsPart part, dynamic shapeHelper) { bool synchRequired = !_workContextAccessor.GetContext() .CurrentSite.As <InventoryBySKUSiteSettingsPart>().InventoriesAreAllInSynch; List <ProductPart> badProducts = new List <ProductPart>(); if (synchRequired) { badProducts = _productInventoryService.GetProductsWithInventoryIssues().ToList(); synchRequired = badProducts.Any(); } if (!synchRequired) { _workContextAccessor.GetContext() .CurrentSite.As <InventoryBySKUSiteSettingsPart>().InventoriesAreAllInSynch = true; } var model = new InventoryBySKUSiteSettingsPartViewModel() { InventoriesNeedSynch = synchRequired, BadProducts = badProducts }; return(ContentShape("SiteSettings_InventoryBySKU", () => shapeHelper.EditorTemplate( TemplateName: "SiteSettings/InventoryBySKU", Model: model, Prefix: Prefix )).OnGroup("ECommerceSiteSettings")); }
public void Enabled(Feature feature) { if (feature.Descriptor.Id == "Nwazet.InventoryBySKU") { //the feature has just been enabled, so maybe the inventories are not in synch _orchardServices.WorkContext.CurrentSite.As <InventoryBySKUSiteSettingsPart>().InventoriesAreAllInSynch = !_productInventoryService.GetProductsWithInventoryIssues().Any(); } }