From ffa626e3a765f3058ec98d99b1786b7535cc7bb0 Mon Sep 17 00:00:00 2001 From: Kaz Date: Fri, 24 Mar 2017 19:59:57 +1100 Subject: [PATCH] - Migrated .net core projects from legacy structure to habitat structure. --- Sitecore.Demo.Retail.sln | 86 +- global.json | 2 +- gulpfile.js | 37 +- install-commerce-config.json | 2 +- .../Engine.Entitlements/ConfigureSitecore.cs | 46 + .../Entities/DigitalProduct.cs | 6 + .../Entities/Installation.cs | 6 + .../Engine.Entitlements/Entities/Warranty.cs | 6 + .../EntitlementsConstants.cs | 27 + ...gitalProductEntitlementDetailsViewBlock.cs | 58 +- ...InstallationEntitlementDetailsViewBlock.cs | 58 +- ...omerWarrantyEntitlementDetailsViewBlock.cs | 58 +- ...gitalProductEntitlementDetailsViewBlock.cs | 58 +- ...InstallationEntitlementDetailsViewBlock.cs | 57 +- ...rderWarrantyEntitlementDetailsViewBlock.cs | 58 +- ...rovisionDigitalProductEntitlementsBlock.cs | 64 +- .../ProvisionInstallationEntitlementsBlock.cs | 64 +- .../ProvisionWarrantyEntitlementsBlock.cs | 63 +- .../Policies/KnownEntitlementsTags.cs | 21 +- .../Properties/AssemblyInfo.cs | 24 +- ...Commerce.Engine.Plugin.Entitlements.xproj} | 10 +- .../Engine.Entitlements/project.json | 17 + .../Engine.Payments/ConfigureSitecore.cs | 53 + .../Helpers/ComponentsHelper.cs | 21 + .../Engine.Payments/PaymentsConstants.cs | 31 + .../Blocks/CreateFederatedPaymentBlock.cs | 48 +- .../EnsureSettlePaymentRequestedBlock.cs | 62 +- .../Pipelines/Blocks/GetClientTokenBlock.cs | 22 +- .../Blocks/RefundFederatedPaymentBlock.cs | 66 +- ...ateFederatedPaymentAfterSettlementBlock.cs | 46 + .../Blocks/UpdateFederatedPaymentBlock.cs | 62 +- .../Blocks/ValidateSettlementBlock.cs | 51 +- .../VoidCancelOrderFederatedPaymentBlock.cs | 65 +- .../Policies/BraintreeClientPolicy.cs | 20 + .../Properties/AssemblyInfo.cs | 4 +- ...ion.Commerce.Engine.Plugin.Payments.xproj} | 4 +- .../Engine.Payments/project.json | 15 + .../CartPipelineExtentions.cs | 43 + ...InitializeEnvironmentPipelineExtentions.cs | 24 + .../OrdersPipelinesExtentions.cs | 22 + .../RunningPluginsPipelineExtentions.cs | 25 + .../ApplicationInsightsExtentions.cs} | 8 +- .../CommerceEnvironmentExtentions.cs} | 20 +- .../CommerceNodeExtentions.cs} | 17 +- .../DataProtectionExtentions.cs} | 6 +- .../ErrorPageExtentions.cs} | 6 +- .../LoggingExtentions.cs} | 6 +- .../ODataExtentions.cs} | 6 +- .../SettingsExtentions.cs} | 6 +- .../SitecoreExtentions.cs} | 6 +- .../Engine/{code => }/ApplicationLogging.cs | 0 .../Engine/CommerceEngineConstants.cs | 17 + .../Commerce/Engine/ConfigureSitecore.cs | 26 + .../{code => }/DiagnosticsExtensions.cs | 5 - .../Blocks/BootstrapManagedListsBlock.cs | 37 + .../Pipelines/Blocks/RegisteredPluginBlock.cs | 25 + .../Commerce/Engine/Plugin/code/Class1.cs | 14 - .../Commerce/Engine/Plugin/code/project.json | 14 - .../Commerce/Engine/{code => }/Program.cs | 0 .../{code => }/Properties/launchSettings.json | 0 .../Sitecore.Foundation.Commerce.Engine.xproj | 0 src/Foundation/Commerce/Engine/Startup.cs | 72 + .../Commerce/Engine/code/App_Start/Startup.cs | 93 - .../Commerce/Engine/code/Startup.cs | 368 --- .../Commerce/Engine/{code => }/project.json | 10 +- .../Commerce/Engine/{code => }/web.config | 0 .../{code => }/wwwroot/bootstrap/Global.json | 0 .../Engine/{code => }/wwwroot/config.json | 0 .../data/Environments/CommerceOps-1.0.0.json | 0 .../Habitat.CommerceAuthoring-1.0.0.json | 0 .../Habitat.CommerceMinions-1.0.0.json | 0 .../Habitat.CommerceShops-1.0.0.json | 0 .../Engine/{code => }/wwwroot/web.config | 0 .../ConfigureSitecore.cs | 68 - .../Controller/CommandsController.cs | 29 - .../Entities/DigitalProduct.cs | 18 - .../Entities/Installation.cs | 18 - .../Entities/Warranty.cs | 18 - .../Plugin.Sample.Habitat/HabitatConstants.cs | 76 - .../Pipelines/Arguments/SampleArgument.cs | 35 - ...InitializeEnvironmentEnsureCatalogBlock.cs | 55 - .../InitializeEnvironmentGiftCardsBlock.cs | 130 - .../Plugin.Sample.Habitat/project.json | 58 - .../ConfigureSitecore.cs | 68 - .../Helpers/ComponentsHelper.cs | 36 - .../PaymentsBraintreeConstants.cs | 76 - ...ateFederatedPaymentAfterSettlementBlock.cs | 74 - .../Plugin.Sample.Payments.Braintree.xproj | 28 - .../Policies/BraintreeClientPolicy.cs | 59 - .../project.json | 54 - .../AwConstants.cs | 89 - .../ConfigureSitecore.cs | 55 - .../Blocks/BootstrapAwEnvironmentBlock.cs | 537 ---- .../Blocks/BootstrapManagedListsBlock.cs | 70 - .../InitializeEnvironmentPolicySetsBlock.cs | 101 - .../InitializeEnvironmentPricingBlock.cs | 296 -- .../InitializeEnvironmentPromotionsBlock.cs | 1306 --------- .../InitializeEnvironmentRegionsBlock.cs | 106 - ...InitializeEnvironmentSellableItemsBlock.cs | 2387 ----------------- .../Blocks/InitializeEnvironmentShopsBlock.cs | 245 -- .../Pipelines/Blocks/RegisteredPluginBlock.cs | 49 - .../ServiceCollectionExtensions.cs | 84 - .../build.not | 0 .../project.json | 73 - .../Engine.HabitatData/ConfigureSitecore.cs | 32 + .../HabitatDataConstants.cs | 27 + .../InitializeEnvironmentGiftCardsBlock.cs | 94 + .../InitializeEnvironmentPricingBlock.cs | 60 +- .../InitializeEnvironmentPromotionsBlock.cs | 71 +- ...InitializeEnvironmentSellableItemsBlock.cs | 96 +- .../Properties/AssemblyInfo.cs | 24 +- ....Commerce.Engine.Plugin.HabitatData.xproj} | 13 +- .../Retail/Engine.HabitatData/project.json | 19 + 113 files changed, 1223 insertions(+), 7785 deletions(-) create mode 100644 src/Foundation/Commerce.Entitlements/Engine.Entitlements/ConfigureSitecore.cs create mode 100644 src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/DigitalProduct.cs create mode 100644 src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Installation.cs create mode 100644 src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Warranty.cs create mode 100644 src/Foundation/Commerce.Entitlements/Engine.Entitlements/EntitlementsConstants.cs rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs (60%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs (60%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs (60%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs (60%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs (60%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs (60%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs (68%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs (68%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs (68%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Policies/KnownEntitlementsTags.cs (58%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat => Commerce.Entitlements/Engine.Entitlements}/Properties/AssemblyInfo.cs (51%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Habitat/Plugin.Sample.Habitat.xproj => Commerce.Entitlements/Engine.Entitlements/Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.xproj} (70%) create mode 100644 src/Foundation/Commerce.Entitlements/Engine.Entitlements/project.json create mode 100644 src/Foundation/Commerce.Payments/Engine.Payments/ConfigureSitecore.cs create mode 100644 src/Foundation/Commerce.Payments/Engine.Payments/Helpers/ComponentsHelper.cs create mode 100644 src/Foundation/Commerce.Payments/Engine.Payments/PaymentsConstants.cs rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/CreateFederatedPaymentBlock.cs (73%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs (73%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/GetClientTokenBlock.cs (74%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/RefundFederatedPaymentBlock.cs (78%) create mode 100644 src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs (82%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/ValidateSettlementBlock.cs (66%) rename src/Foundation/{Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree => Commerce.Payments/Engine.Payments}/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs (70%) create mode 100644 src/Foundation/Commerce.Payments/Engine.Payments/Policies/BraintreeClientPolicy.cs rename src/Foundation/{Commerce/Engine/Plugin/code => Commerce.Payments/Engine.Payments}/Properties/AssemblyInfo.cs (83%) rename src/Foundation/{Commerce/Engine/Plugin/code/Sitecore.Foundation.Commerce.Engine.Plugin.Habitat.xproj => Commerce.Payments/Engine.Payments/Sitecore.Foundation.Commerce.Engine.Plugin.Payments.xproj} (86%) create mode 100644 src/Foundation/Commerce.Payments/Engine.Payments/project.json create mode 100644 src/Foundation/Commerce/Engine/App_ConfigureSitecore/CartPipelineExtentions.cs create mode 100644 src/Foundation/Commerce/Engine/App_ConfigureSitecore/InitializeEnvironmentPipelineExtentions.cs create mode 100644 src/Foundation/Commerce/Engine/App_ConfigureSitecore/OrdersPipelinesExtentions.cs create mode 100644 src/Foundation/Commerce/Engine/App_ConfigureSitecore/RunningPluginsPipelineExtentions.cs rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigApplicationInsights.cs => App_Startup/ApplicationInsightsExtentions.cs} (67%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigEnvironment.cs => App_Startup/CommerceEnvironmentExtentions.cs} (58%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigNode.cs => App_Startup/CommerceNodeExtentions.cs} (74%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigDataProtection.cs => App_Startup/DataProtectionExtentions.cs} (91%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigErrorPage.cs => App_Startup/ErrorPageExtentions.cs} (66%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigLogging.cs => App_Startup/LoggingExtentions.cs} (91%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigOData.cs => App_Startup/ODataExtentions.cs} (81%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigSettings.cs => App_Startup/SettingsExtentions.cs} (76%) rename src/Foundation/Commerce/Engine/{code/App_Start/ConfigSitecore.cs => App_Startup/SitecoreExtentions.cs} (83%) rename src/Foundation/Commerce/Engine/{code => }/ApplicationLogging.cs (100%) create mode 100644 src/Foundation/Commerce/Engine/CommerceEngineConstants.cs create mode 100644 src/Foundation/Commerce/Engine/ConfigureSitecore.cs rename src/Foundation/Commerce/Engine/{code => }/DiagnosticsExtensions.cs (66%) create mode 100644 src/Foundation/Commerce/Engine/Pipelines/Blocks/BootstrapManagedListsBlock.cs create mode 100644 src/Foundation/Commerce/Engine/Pipelines/Blocks/RegisteredPluginBlock.cs delete mode 100644 src/Foundation/Commerce/Engine/Plugin/code/Class1.cs delete mode 100644 src/Foundation/Commerce/Engine/Plugin/code/project.json rename src/Foundation/Commerce/Engine/{code => }/Program.cs (100%) rename src/Foundation/Commerce/Engine/{code => }/Properties/launchSettings.json (100%) rename src/Foundation/Commerce/Engine/{code => }/Sitecore.Foundation.Commerce.Engine.xproj (100%) create mode 100644 src/Foundation/Commerce/Engine/Startup.cs delete mode 100644 src/Foundation/Commerce/Engine/code/App_Start/Startup.cs delete mode 100644 src/Foundation/Commerce/Engine/code/Startup.cs rename src/Foundation/Commerce/Engine/{code => }/project.json (82%) rename src/Foundation/Commerce/Engine/{code => }/web.config (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/bootstrap/Global.json (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/config.json (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/data/Environments/CommerceOps-1.0.0.json (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/data/Environments/Habitat.CommerceAuthoring-1.0.0.json (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/data/Environments/Habitat.CommerceMinions-1.0.0.json (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/data/Environments/Habitat.CommerceShops-1.0.0.json (100%) rename src/Foundation/Commerce/Engine/{code => }/wwwroot/web.config (100%) delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/ConfigureSitecore.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Controller/CommandsController.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/DigitalProduct.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Installation.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Warranty.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/HabitatConstants.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Arguments/SampleArgument.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentEnsureCatalogBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/project.json delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/ConfigureSitecore.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Helpers/ComponentsHelper.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/PaymentsBraintreeConstants.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Plugin.Sample.Payments.Braintree.xproj delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Policies/BraintreeClientPolicy.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/project.json delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/AwConstants.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ConfigureSitecore.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapAwEnvironmentBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapManagedListsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPolicySetsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentRegionsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentShopsBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/RegisteredPluginBlock.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ServiceCollectionExtensions.cs delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/build.not delete mode 100644 src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/project.json create mode 100644 src/Project/Retail/Engine.HabitatData/ConfigureSitecore.cs create mode 100644 src/Project/Retail/Engine.HabitatData/HabitatDataConstants.cs create mode 100644 src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs rename src/{Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat => Project/Retail/Engine.HabitatData}/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs (90%) rename src/{Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat => Project/Retail/Engine.HabitatData}/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs (95%) rename src/{Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat => Project/Retail/Engine.HabitatData}/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs (55%) rename src/{Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks => Project/Retail/Engine.HabitatData}/Properties/AssemblyInfo.cs (50%) rename src/{Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Sitecore.Commerce.Plugin.AdventureWorks.xproj => Project/Retail/Engine.HabitatData/Sitecore.Project.Commerce.Engine.Plugin.HabitatData.xproj} (62%) create mode 100644 src/Project/Retail/Engine.HabitatData/project.json diff --git a/Sitecore.Demo.Retail.sln b/Sitecore.Demo.Retail.sln index 6b62052d..2b7097f6 100644 --- a/Sitecore.Demo.Retail.sln +++ b/Sitecore.Demo.Retail.sln @@ -50,20 +50,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.Foundation.Depende EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{C01BE502-C648-4368-84FC-3F2B212541BC}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Foundation.Commerce.Engine", "src\Foundation\Commerce\Engine\code\Sitecore.Foundation.Commerce.Engine.xproj", "{7F35C803-0290-4BFD-A806-F1EDDF1E24D2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Commerce.Entitlements", "Commerce.Entitlements", "{717FA6E0-F01B-4491-9254-48620F5A44A7}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugin", "Plugin", "{9633DAAE-84BB-48E3-9F39-BAC6E9133CC1}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Foundation.Commerce.Engine.Plugin.Habitat", "src\Foundation\Commerce\Engine\Plugin\Code\Sitecore.Foundation.Commerce.Engine.Plugin.Habitat.xproj", "{16A75548-B717-41D9-A55A-D1E68765E530}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Commerce.Plugin.AdventureWorks", "src\Foundation\Commerce\legacyCommerce\Sitecore.Commerce.Plugin.AdventureWorks\Sitecore.Commerce.Plugin.AdventureWorks.xproj", "{45E1A5F7-861D-4929-A4C4-E3FD9D898F23}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Plugin.Sample.Payments.Braintree", "src\Foundation\Commerce\legacyCommerce\Plugin.Sample.Payments.Braintree\Plugin.Sample.Payments.Braintree.xproj", "{0296F347-F76D-4A81-9FB1-AE9CA0F0C064}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Plugin.Sample.Habitat", "src\Foundation\Commerce\legacyCommerce\Plugin.Sample.Habitat\Plugin.Sample.Habitat.xproj", "{72203E4B-DA74-405C-9D33-193B38A0AA33}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Commerce.Payments", "Commerce.Payments", "{2247437C-D41C-4E67-A509-E2870B1BB3E2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.Feature.Commerce.Orders", "src\Feature\Orders\code\Sitecore.Feature.Commerce.Orders.csproj", "{9CC4BF07-1259-43FF-B205-AFD1E59E5834}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Database", "Database", "{BA71DDCB-F72A-42A8-86EE-E81669BC5F1A}" + ProjectSection(SolutionItems) = preProject + src\Foundation\Commerce\Database\CommerceServicesDbScript.sql = src\Foundation\Commerce\Database\CommerceServicesDbScript.sql + EndProjectSection +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Databases", "Databases", "{8B1B7EE8-17D0-4D90-BABD-249C971EBDFB}" ProjectSection(SolutionItems) = preProject src\Project\Retail\Database\Catalog.xml = src\Project\Retail\Database\Catalog.xml @@ -71,6 +68,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Databases", "Databases", "{ src\Project\Retail\Database\Profiles.xml = src\Project\Retail\Database\Profiles.xml EndProjectSection EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Project.Commerce.Engine.Plugin.HabitatData", "src\Project\Retail\Engine.HabitatData\Sitecore.Project.Commerce.Engine.Plugin.HabitatData.xproj", "{B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Foundation.Commerce.Engine", "src\Foundation\Commerce\Engine\Sitecore.Foundation.Commerce.Engine.xproj", "{7F35C803-0290-4BFD-A806-F1EDDF1E24D2}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements", "src\Foundation\Commerce.Entitlements\Engine.Entitlements\Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.xproj", "{47A05070-727E-444F-85A8-CF50620ACE04}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sitecore.Foundation.Commerce.Engine.Plugin.Payments", "src\Foundation\Commerce.Payments\Engine.Payments\Sitecore.Foundation.Commerce.Engine.Plugin.Payments.xproj", "{7AC44B7F-641E-4284-A182-C962E5D56C3F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -115,37 +120,36 @@ Global {366148B7-2392-4F42-80D6-786B7A3682AE}.Demo-Retail|Any CPU.Build.0 = Demo-Retail|Any CPU {366148B7-2392-4F42-80D6-786B7A3682AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {366148B7-2392-4F42-80D6-786B7A3682AE}.Release|Any CPU.Build.0 = Release|Any CPU - {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU - {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Release|Any CPU.Build.0 = Release|Any CPU - {16A75548-B717-41D9-A55A-D1E68765E530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {16A75548-B717-41D9-A55A-D1E68765E530}.Debug|Any CPU.Build.0 = Debug|Any CPU - {16A75548-B717-41D9-A55A-D1E68765E530}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU - {16A75548-B717-41D9-A55A-D1E68765E530}.Release|Any CPU.ActiveCfg = Release|Any CPU - {16A75548-B717-41D9-A55A-D1E68765E530}.Release|Any CPU.Build.0 = Release|Any CPU - {45E1A5F7-861D-4929-A4C4-E3FD9D898F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {45E1A5F7-861D-4929-A4C4-E3FD9D898F23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {45E1A5F7-861D-4929-A4C4-E3FD9D898F23}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU - {45E1A5F7-861D-4929-A4C4-E3FD9D898F23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {45E1A5F7-861D-4929-A4C4-E3FD9D898F23}.Release|Any CPU.Build.0 = Release|Any CPU - {0296F347-F76D-4A81-9FB1-AE9CA0F0C064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0296F347-F76D-4A81-9FB1-AE9CA0F0C064}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0296F347-F76D-4A81-9FB1-AE9CA0F0C064}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU - {0296F347-F76D-4A81-9FB1-AE9CA0F0C064}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0296F347-F76D-4A81-9FB1-AE9CA0F0C064}.Release|Any CPU.Build.0 = Release|Any CPU - {72203E4B-DA74-405C-9D33-193B38A0AA33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72203E4B-DA74-405C-9D33-193B38A0AA33}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72203E4B-DA74-405C-9D33-193B38A0AA33}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU - {72203E4B-DA74-405C-9D33-193B38A0AA33}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72203E4B-DA74-405C-9D33-193B38A0AA33}.Release|Any CPU.Build.0 = Release|Any CPU {9CC4BF07-1259-43FF-B205-AFD1E59E5834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9CC4BF07-1259-43FF-B205-AFD1E59E5834}.Debug|Any CPU.Build.0 = Debug|Any CPU {9CC4BF07-1259-43FF-B205-AFD1E59E5834}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU {9CC4BF07-1259-43FF-B205-AFD1E59E5834}.Demo-Retail|Any CPU.Build.0 = Demo-Retail|Any CPU {9CC4BF07-1259-43FF-B205-AFD1E59E5834}.Release|Any CPU.ActiveCfg = Release|Any CPU {9CC4BF07-1259-43FF-B205-AFD1E59E5834}.Release|Any CPU.Build.0 = Release|Any CPU + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}.Demo-Retail|Any CPU.ActiveCfg = Debug|Any CPU + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}.Demo-Retail|Any CPU.Build.0 = Debug|Any CPU + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42}.Release|Any CPU.Build.0 = Release|Any CPU + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Demo-Retail|Any CPU.ActiveCfg = Demo-Retail|Any CPU + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Demo-Retail|Any CPU.Build.0 = Demo-Retail|Any CPU + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2}.Release|Any CPU.Build.0 = Release|Any CPU + {47A05070-727E-444F-85A8-CF50620ACE04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47A05070-727E-444F-85A8-CF50620ACE04}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47A05070-727E-444F-85A8-CF50620ACE04}.Demo-Retail|Any CPU.ActiveCfg = Debug|Any CPU + {47A05070-727E-444F-85A8-CF50620ACE04}.Demo-Retail|Any CPU.Build.0 = Debug|Any CPU + {47A05070-727E-444F-85A8-CF50620ACE04}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47A05070-727E-444F-85A8-CF50620ACE04}.Release|Any CPU.Build.0 = Release|Any CPU + {7AC44B7F-641E-4284-A182-C962E5D56C3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AC44B7F-641E-4284-A182-C962E5D56C3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AC44B7F-641E-4284-A182-C962E5D56C3F}.Demo-Retail|Any CPU.ActiveCfg = Debug|Any CPU + {7AC44B7F-641E-4284-A182-C962E5D56C3F}.Demo-Retail|Any CPU.Build.0 = Debug|Any CPU + {7AC44B7F-641E-4284-A182-C962E5D56C3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AC44B7F-641E-4284-A182-C962E5D56C3F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -165,13 +169,13 @@ Global {A17F2B02-CD42-43C7-BAF6-823A87E3CA5B} = {A65C1E2B-A56A-4E86-B928-23176FC86DB8} {366148B7-2392-4F42-80D6-786B7A3682AE} = {A17F2B02-CD42-43C7-BAF6-823A87E3CA5B} {C01BE502-C648-4368-84FC-3F2B212541BC} = {F12F210F-76B3-4142-8AB9-06677BCAED1E} - {7F35C803-0290-4BFD-A806-F1EDDF1E24D2} = {C01BE502-C648-4368-84FC-3F2B212541BC} - {9633DAAE-84BB-48E3-9F39-BAC6E9133CC1} = {C01BE502-C648-4368-84FC-3F2B212541BC} - {16A75548-B717-41D9-A55A-D1E68765E530} = {9633DAAE-84BB-48E3-9F39-BAC6E9133CC1} - {45E1A5F7-861D-4929-A4C4-E3FD9D898F23} = {0639A703-FE73-43C9-8F19-5E62FA008BC3} - {0296F347-F76D-4A81-9FB1-AE9CA0F0C064} = {0639A703-FE73-43C9-8F19-5E62FA008BC3} - {72203E4B-DA74-405C-9D33-193B38A0AA33} = {0639A703-FE73-43C9-8F19-5E62FA008BC3} + {717FA6E0-F01B-4491-9254-48620F5A44A7} = {A65C1E2B-A56A-4E86-B928-23176FC86DB8} + {2247437C-D41C-4E67-A509-E2870B1BB3E2} = {A65C1E2B-A56A-4E86-B928-23176FC86DB8} {9CC4BF07-1259-43FF-B205-AFD1E59E5834} = {A796DED4-AE86-4E8F-BBAF-B57960008D59} {8B1B7EE8-17D0-4D90-BABD-249C971EBDFB} = {B3C10EC2-6B18-480D-8C75-CE4929838289} + {B02C5772-DF1E-48E5-B5EC-084ECF8A0B42} = {B3C10EC2-6B18-480D-8C75-CE4929838289} + {7F35C803-0290-4BFD-A806-F1EDDF1E24D2} = {C01BE502-C648-4368-84FC-3F2B212541BC} + {47A05070-727E-444F-85A8-CF50620ACE04} = {717FA6E0-F01B-4491-9254-48620F5A44A7} + {7AC44B7F-641E-4284-A182-C962E5D56C3F} = {2247437C-D41C-4E67-A509-E2870B1BB3E2} EndGlobalSection EndGlobal diff --git a/global.json b/global.json index aa7f8b94..bd85ca0d 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { - "projects": [ "src/Foundation/Commerce/legacyCommerce" ], + "projects": [ "src/Foundation/Commerce/legacyCommerce", "src/Project/Retail", "src/Foundation/Commerce.Payments", "src/Foundation/Commerce.Entitlements" ], "sdk": { "version": "1.0.0-preview2-003131" } diff --git a/gulpfile.js b/gulpfile.js index 0d3d6849..cedb52f9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -152,6 +152,7 @@ var publishProjects = function (location, dest) { }; gulp.task("Build-Solution", function () { + console.log("Building Solution"); var targets = ["Build"]; if (config.runCleanBuilds) { targets = ["Clean", "Build"]; @@ -171,6 +172,7 @@ gulp.task("Build-Solution", function () { }); gulp.task("Publish-Storefront-Projects", function () { + console.log("Publishing Storefront Projects"); return publishProjects("./src/Foundation/Commerce/storefront/{CommonSettings,CF/CSF}"); }); @@ -363,7 +365,7 @@ gulp.task("CE-01-Nuget-Restore", function (callback) { }); gulp.task("CE-02-Publish-CommerceEngine-Projects", function (callback) { - var cmd = "dotnet publish ./src/Foundation/Commerce/Engine/code -o " + config.commerceEngineRoot + var cmd = "dotnet publish ./src/Foundation/Commerce/Engine -o " + config.commerceEngineRoot var options = { maxBuffer: 1024 * 1024 }; console.log("cmd: " + cmd); return exec(cmd, options, function (err, stdout, stderr) { @@ -424,4 +426,37 @@ gulp.task("CE-Import-CSInventory", function (callback) { console.log("stderr: " + stderr); callback(); }); +}); + +/***************************** + Kill Tasks +*****************************/ +gulp.task("Kill-w3wp-Tasks", function (callback) { + var cmd = "@tskill w3wp /a /v" + var options = { maxBuffer: 1024 * 1024 }; + console.log("cmd: " + cmd); + return exec(cmd, options, function (err, stdout, stderr) { + if ((err) && (!stderr.includes("Could not find process"))) { + console.error("exec error: " + err); + throw err; + } + console.log("stdout: " + stdout); + console.log("stderr: " + stderr); + callback(); + }); +}); + +gulp.task("Kill-iisexpress-Tasks", function (callback) { + var cmd = "@tskill iisexpress /a /v" + var options = { maxBuffer: 1024 * 1024 }; + console.log("cmd: " + cmd); + return exec(cmd, options, function (err, stdout, stderr) { + if ((err) && (!stderr.includes("Could not find process"))) { + console.error("exec error: " + err); + throw err; + } + console.log("stdout: " + stdout); + console.log("stderr: " + stderr); + callback(); + }); }); \ No newline at end of file diff --git a/install-commerce-config.json b/install-commerce-config.json index 8c25e376..ba9c96a5 100644 --- a/install-commerce-config.json +++ b/install-commerce-config.json @@ -38,7 +38,7 @@ } ], [ { "id": "commerceEngineProject", - "path": ".\\src\\Foundation\\Commerce\\Engine\\code", + "path": ".\\src\\Foundation\\Commerce\\Engine", "files": [] } ], diff --git a/src/Foundation/Commerce.Entitlements/Engine.Entitlements/ConfigureSitecore.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/ConfigureSitecore.cs new file mode 100644 index 00000000..56b57635 --- /dev/null +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/ConfigureSitecore.cs @@ -0,0 +1,46 @@ +using System.Reflection; + +using Microsoft.Extensions.DependencyInjection; + +using Sitecore.Framework.Configuration; +using Sitecore.Framework.Pipelines.Definitions.Extensions; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.EntityViews; + +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks; + + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements +{ + public class ConfigureSitecore : IConfigureSitecore + { + public void ConfigureServices(IServiceCollection services) + { + var assembly = Assembly.GetExecutingAssembly(); + services.RegisterAllPipelineBlocks(assembly); + services.RegisterAllCommands(assembly); + + services.Sitecore().Pipelines(config => config + + .ConfigurePipeline(c => + { + c.Add().After() + .Add().After() + .Add().After(); + }) + + .ConfigurePipeline(c => + { + c.Add().After() + .Add().After() + .Add().After() + .Add().After() + .Add().After() + .Add().After(); + }) + ); + } + } +} diff --git a/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/DigitalProduct.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/DigitalProduct.cs new file mode 100644 index 00000000..206e243f --- /dev/null +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/DigitalProduct.cs @@ -0,0 +1,6 @@ +using Sitecore.Commerce.Plugin.Entitlements; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities +{ + public class DigitalProduct : Entitlement {} +} \ No newline at end of file diff --git a/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Installation.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Installation.cs new file mode 100644 index 00000000..331ace24 --- /dev/null +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Installation.cs @@ -0,0 +1,6 @@ +using Sitecore.Commerce.Plugin.Entitlements; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities +{ + public class Installation : Entitlement {} +} \ No newline at end of file diff --git a/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Warranty.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Warranty.cs new file mode 100644 index 00000000..7992d7a0 --- /dev/null +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Entities/Warranty.cs @@ -0,0 +1,6 @@ +using Sitecore.Commerce.Plugin.Entitlements; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities +{ + public class Warranty : Entitlement {} +} \ No newline at end of file diff --git a/src/Foundation/Commerce.Entitlements/Engine.Entitlements/EntitlementsConstants.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/EntitlementsConstants.cs new file mode 100644 index 00000000..39a2636a --- /dev/null +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/EntitlementsConstants.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements +{ + public static class EntitlementsConstants + { + public static class Pipelines + { + public static class Blocks + { + public const string ProvisionWarrantyEntitlementsBlock = "Entitlements.block.ProvisionWarrantyEntitlements"; + public const string ProvisionInstallationEntitlementsBlock = "Entitlements.block.ProvisionInstallationEntitlements"; + public const string ProvisionDigitalProductEntitlementsBlock = "Entitlements.block.ProvisionDigitalProductEntitlements"; + public const string GetOrderWarrantyEntitlementDetailsViewBlock = "Entitlements.block.GetOrderWarrantyEntitlementDetailsView"; + public const string GetCustomerWarrantyEntitlementDetailsViewBlock = "Entitlements.block.GetCustomerWarrantyEntitlementDetailsView"; + public const string GetOrderInstallationEntitlementDetailsViewBlock = "Entitlements.block.GetOrderInstallationEntitlementDetailsView"; + public const string GetCustomerInstallationEntitlementDetailsViewBlock = "Entitlements.block.GetCustomerInstallationEntitlementDetailsView"; + public const string GetOrderDigitalProductEntitlementDetailsViewBlock = "Entitlements.block.GetOrderDigitalProductEntitlementDetailsView"; + public const string GetCustomerDigitalProductEntitlementDetailsViewBlock = "Entitlements.block.GetCustomerDigitalProductEntitlementDetailsView"; + } + } + } +} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs similarity index 60% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs index 143c86ba..7b0a1d63 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerDigitalProductEntitlementDetailsViewBlock.cs @@ -1,58 +1,28 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Linq; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Commands; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Customers; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core.Commands; +using Sitecore.Commerce.EntityViews; +using Sitecore.Commerce.Plugin.Customers; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the get order digital product entitlement details view block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.EntityViews.EntityView, - /// Sitecore.Commerce.EntityViews.EntityView, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.GetCustomerDigitalProductEntitlementDetailsViewBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.GetCustomerDigitalProductEntitlementDetailsViewBlock)] public class GetCustomerDigitalProductEntitlementDetailsViewBlock : PipelineBlock { private readonly FindEntityCommand _findEntityCommand; - /// - /// Initializes a new instance of the class. - /// - /// The find entity command. public GetCustomerDigitalProductEntitlementDetailsViewBlock(FindEntityCommand findEntityCommand) { this._findEntityCommand = findEntityCommand; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs similarity index 60% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs index 861cc663..3dfb78de 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerInstallationEntitlementDetailsViewBlock.cs @@ -1,58 +1,28 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Linq; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Commands; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Customers; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core.Commands; +using Sitecore.Commerce.EntityViews; +using Sitecore.Commerce.Plugin.Customers; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the get order installation entitlement details view block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.EntityViews.EntityView, - /// Sitecore.Commerce.EntityViews.EntityView, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.GetCustomerInstallationEntitlementDetailsViewBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.GetCustomerInstallationEntitlementDetailsViewBlock)] public class GetCustomerInstallationEntitlementDetailsViewBlock : PipelineBlock { private readonly FindEntityCommand _findEntityCommand; - /// - /// Initializes a new instance of the class. - /// - /// The find entity command. public GetCustomerInstallationEntitlementDetailsViewBlock(FindEntityCommand findEntityCommand) { this._findEntityCommand = findEntityCommand; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs similarity index 60% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs index e46749b0..230b37b3 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetCustomerWarrantyEntitlementDetailsViewBlock.cs @@ -1,58 +1,28 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Linq; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Commands; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Customers; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core.Commands; +using Sitecore.Commerce.EntityViews; +using Sitecore.Commerce.Plugin.Customers; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the get order warranty entitlement details view block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.EntityViews.EntityView, - /// Sitecore.Commerce.EntityViews.EntityView, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.GetCustomerWarrantyEntitlementDetailsViewBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.GetCustomerWarrantyEntitlementDetailsViewBlock)] public class GetCustomerWarrantyEntitlementDetailsViewBlock : PipelineBlock { private readonly FindEntityCommand _findEntityCommand; - /// - /// Initializes a new instance of the class. - /// - /// The find entity command. public GetCustomerWarrantyEntitlementDetailsViewBlock(FindEntityCommand findEntityCommand) { this._findEntityCommand = findEntityCommand; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs similarity index 60% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs index a0fbd1f3..1671fc2a 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderDigitalProductEntitlementDetailsViewBlock.cs @@ -1,58 +1,28 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Linq; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Commands; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core.Commands; +using Sitecore.Commerce.EntityViews; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the get order digital product entitlement details view block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.EntityViews.EntityView, - /// Sitecore.Commerce.EntityViews.EntityView, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.GetOrderDigitalProductEntitlementDetailsViewBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.GetOrderDigitalProductEntitlementDetailsViewBlock)] public class GetOrderDigitalProductEntitlementDetailsViewBlock : PipelineBlock { private readonly FindEntityCommand _findEntityCommand; - /// - /// Initializes a new instance of the class. - /// - /// The find entity command. public GetOrderDigitalProductEntitlementDetailsViewBlock(FindEntityCommand findEntityCommand) { this._findEntityCommand = findEntityCommand; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs similarity index 60% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs index 82abf934..fa2c2a4f 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderInstallationEntitlementDetailsViewBlock.cs @@ -1,58 +1,29 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Linq; - using System.Threading.Tasks; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core.Commands; +using Sitecore.Commerce.EntityViews; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Commands; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews +{ - /// - /// Defines the get order installation entitlement details view block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.EntityViews.EntityView, - /// Sitecore.Commerce.EntityViews.EntityView, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.GetOrderInstallationEntitlementDetailsViewBlock)] + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.GetOrderInstallationEntitlementDetailsViewBlock)] public class GetOrderInstallationEntitlementDetailsViewBlock : PipelineBlock { private readonly FindEntityCommand _findEntityCommand; - /// - /// Initializes a new instance of the class. - /// - /// The find entity command. public GetOrderInstallationEntitlementDetailsViewBlock(FindEntityCommand findEntityCommand) { this._findEntityCommand = findEntityCommand; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs similarity index 60% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs index 2153183e..fb1629fb 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/EntityViews/GetOrderWarrantyEntitlementDetailsViewBlock.cs @@ -1,58 +1,28 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Linq; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Commands; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core.Commands; +using Sitecore.Commerce.EntityViews; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the get order warranty entitlement details view block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.EntityViews.EntityView, - /// Sitecore.Commerce.EntityViews.EntityView, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.GetOrderWarrantyEntitlementDetailsViewBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks.EntityViews +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.GetOrderWarrantyEntitlementDetailsViewBlock)] public class GetOrderWarrantyEntitlementDetailsViewBlock : PipelineBlock { private readonly FindEntityCommand _findEntityCommand; - /// - /// Initializes a new instance of the class. - /// - /// The find entity command. public GetOrderWarrantyEntitlementDetailsViewBlock(FindEntityCommand findEntityCommand) { this._findEntityCommand = findEntityCommand; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs similarity index 68% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs index 0263ed97..7565f51e 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionDigitalProductEntitlementsBlock.cs @@ -1,62 +1,32 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Availability; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Availability; +using Sitecore.Commerce.Plugin.Carts; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Policies; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the provision digital product entitlements block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.Collections.Generic.IEnumerable{Sitecore.Commerce.Plugin.Entitlements.Entitlement}, - /// System.Collections.Generic.IEnumerable{Sitecore.Commerce.Plugin.Entitlements.Entitlement}, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.ProvisionDigitalProductEntitlementsBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.ProvisionDigitalProductEntitlementsBlock)] public class ProvisionDigitalProductEntitlementsBlock : PipelineBlock, IEnumerable, CommercePipelineExecutionContext> { private readonly IPersistEntityPipeline _persistEntityPipeline; - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. public ProvisionDigitalProductEntitlementsBlock(IPersistEntityPipeline persistEntityPipeline) { this._persistEntityPipeline = persistEntityPipeline; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// A list of . - /// public override async Task> Run(IEnumerable arg, CommercePipelineExecutionContext context) { var entitlements = arg as List ?? arg.ToList(); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs similarity index 68% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs index 135664c4..cfbfd12e 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionInstallationEntitlementsBlock.cs @@ -1,63 +1,33 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Availability; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Availability; +using Sitecore.Commerce.Plugin.Carts; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Policies; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - /// - /// Defines the provision installation entitlements block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.Collections.Generic.IEnumerable{Sitecore.Commerce.Plugin.Entitlements.Entitlement}, - /// System.Collections.Generic.IEnumerable{Sitecore.Commerce.Plugin.Entitlements.Entitlement}, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.ProvisionInstallationEntitlementsBlock)] +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks +{ + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.ProvisionInstallationEntitlementsBlock)] public class ProvisionInstallationEntitlementsBlock : PipelineBlock, IEnumerable, CommercePipelineExecutionContext> { private readonly IPersistEntityPipeline _persistEntityPipeline; - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. public ProvisionInstallationEntitlementsBlock( IPersistEntityPipeline persistEntityPipeline) { this._persistEntityPipeline = persistEntityPipeline; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// A list of . - /// public override async Task> Run(IEnumerable arg, CommercePipelineExecutionContext context) { var entitlements = arg as List ?? arg.ToList(); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs similarity index 68% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs index 7d887775..cbfd20ed 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Pipelines/Blocks/ProvisionWarrantyEntitlementsBlock.cs @@ -1,63 +1,34 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; +using Microsoft.Extensions.Logging; - using Microsoft.Extensions.Logging; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Availability; +using Sitecore.Commerce.Plugin.Carts; +using Sitecore.Commerce.Plugin.Entitlements; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Policies; +using Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Entities; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Availability; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Pipelines.Blocks +{ - /// - /// Defines the provision warranty entitlements block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.Collections.Generic.IEnumerable{Sitecore.Commerce.Plugin.Entitlements.Entitlement}, - /// System.Collections.Generic.IEnumerable{Sitecore.Commerce.Plugin.Entitlements.Entitlement}, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.ProvisionWarrantyEntitlementsBlock)] + [PipelineDisplayName(EntitlementsConstants.Pipelines.Blocks.ProvisionWarrantyEntitlementsBlock)] public class ProvisionWarrantyEntitlementsBlock : PipelineBlock, IEnumerable, CommercePipelineExecutionContext> { private readonly IPersistEntityPipeline _persistEntityPipeline; - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. public ProvisionWarrantyEntitlementsBlock( IPersistEntityPipeline persistEntityPipeline) { this._persistEntityPipeline = persistEntityPipeline; } - /// - /// The execute. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// A list of . - /// public override async Task> Run(IEnumerable arg, CommercePipelineExecutionContext context) { var entitlements = arg as List ?? arg.ToList(); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Policies/KnownEntitlementsTags.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Policies/KnownEntitlementsTags.cs similarity index 58% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Policies/KnownEntitlementsTags.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Policies/KnownEntitlementsTags.cs index fb34f1ac..2f568120 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Policies/KnownEntitlementsTags.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Policies/KnownEntitlementsTags.cs @@ -1,24 +1,11 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System.Collections.Generic; -namespace Plugin.Sample.Habitat -{ - using System.Collections.Generic; - - using Sitecore.Commerce.Core; +using Sitecore.Commerce.Core; - /// - /// Defines the known Habitat entitlement tags - /// - /// +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.Policies +{ public class KnownEntitlementsTags : Policy { - /// - /// Initializes a new instance of the class. - /// public KnownEntitlementsTags() { this.WarrantyTags = new List { "Warranty" }; diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Properties/AssemblyInfo.cs b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Properties/AssemblyInfo.cs similarity index 51% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Properties/AssemblyInfo.cs rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Properties/AssemblyInfo.cs index 2a424cc6..210278cd 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Properties/AssemblyInfo.cs +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Properties/AssemblyInfo.cs @@ -1,21 +1,19 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -//----------------------------------------------------------------------- - -using System; -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Plugin.Sample.Habitat")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements")] +[assembly: AssemblyTrademark("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -[assembly: CLSCompliant(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("47a05070-727e-444f-85a8-cf50620ace04")] diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Plugin.Sample.Habitat.xproj b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.xproj similarity index 70% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Plugin.Sample.Habitat.xproj rename to src/Foundation/Commerce.Entitlements/Engine.Entitlements/Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.xproj index 9f9677ba..0692df70 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Plugin.Sample.Habitat.xproj +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements.xproj @@ -6,16 +6,14 @@ - 72203e4b-da74-405c-9d33-193b38a0aa33 - Plugin.Sample.Habitat - ..\artifacts\obj\$(MSBuildProjectName) + 47a05070-727e-444f-85a8-cf50620ace04 + Sitecore.Foundation.Commerce.Engine.Plugin.Entitlements + .\obj .\bin\ + v4.5.2 2.0 - - False - \ No newline at end of file diff --git a/src/Foundation/Commerce.Entitlements/Engine.Entitlements/project.json b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/project.json new file mode 100644 index 00000000..abc4cee5 --- /dev/null +++ b/src/Foundation/Commerce.Entitlements/Engine.Entitlements/project.json @@ -0,0 +1,17 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Braintree": "3.6.0", + "Microsoft.Extensions.DependencyInjection": "1.1.0", + "Sitecore.Commerce.Core": "1.0.2301", + "Sitecore.Commerce.Plugin.Entitlements": "1.0.2301", + "Sitecore.Framework.Configuration": "1.1.42", + "Sitecore.Framework.Pipelines": "2.0.65" + }, + + "frameworks": { + "net452": { + } + } +} diff --git a/src/Foundation/Commerce.Payments/Engine.Payments/ConfigureSitecore.cs b/src/Foundation/Commerce.Payments/Engine.Payments/ConfigureSitecore.cs new file mode 100644 index 00000000..ff3b030a --- /dev/null +++ b/src/Foundation/Commerce.Payments/Engine.Payments/ConfigureSitecore.cs @@ -0,0 +1,53 @@ +using System.Reflection; +using Microsoft.Extensions.DependencyInjection; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Configuration; +using Sitecore.Framework.Pipelines.Definitions.Extensions; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments +{ + public class ConfigureSitecore : IConfigureSitecore + { + public void ConfigureServices(IServiceCollection services) + { + var assembly = Assembly.GetExecutingAssembly(); + services.RegisterAllPipelineBlocks(assembly); + + services.Sitecore().Pipelines(config => config + + .ConfigurePipeline(builder => builder + .Add().After() + ) + + .ConfigurePipeline(builder => builder + .Add().Before() + ) + + .ConfigurePipeline(d => + { + d.Add().After(); + }) + + .ConfigurePipeline(d => + { + d.Add().After() + .Add().After() + .Add().Before(); + }) + + .ConfigurePipeline(d => + { + d.Add().After(); + }) + + .ConfigurePipeline(d => + { + d.Add().After(); + }) + ); + } + } +} diff --git a/src/Foundation/Commerce.Payments/Engine.Payments/Helpers/ComponentsHelper.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Helpers/ComponentsHelper.cs new file mode 100644 index 00000000..3f336034 --- /dev/null +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Helpers/ComponentsHelper.cs @@ -0,0 +1,21 @@ +using global::Braintree; +using Sitecore.Commerce.Core; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Helpers +{ + public class ComponentsHelper + { + internal static protected AddressRequest TranslatePartyToAddressRequest(Party party, CommercePipelineExecutionContext context) + { + var addressRequest = new AddressRequest(); + addressRequest.CountryCodeAlpha2 = party.CountryCode; + addressRequest.CountryName = party.Country; + addressRequest.FirstName = party.FirstName; + addressRequest.LastName = party.LastName; + addressRequest.PostalCode = party.ZipPostalCode; + addressRequest.StreetAddress = string.Concat(party.Address1, ",", party.Address2); + + return addressRequest; + } + } +} diff --git a/src/Foundation/Commerce.Payments/Engine.Payments/PaymentsConstants.cs b/src/Foundation/Commerce.Payments/Engine.Payments/PaymentsConstants.cs new file mode 100644 index 00000000..726df397 --- /dev/null +++ b/src/Foundation/Commerce.Payments/Engine.Payments/PaymentsConstants.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments +{ + public static class PaymentsConstants + { + public static class Pipelines + { + /// + /// The name of the payment pipelines blocks. + /// + public static class Blocks + { + public const string GetClientTokenBlock = "Payments.block.getclienttoken"; + public const string UpdateFederatedPaymentBlock = "Payments.block.updatefederatedpayment"; + public const string UpdateFederatedPaymentAfterSettlementBlock = "Payments.block.updatefederatedpaymentaftersettlement"; + public const string CreateFederatedPaymentBlock = "Payments.block.createfederatedpayment"; + public const string EnsureSettlePaymentRequestedBlock = "Payments.block.ensuresettlepaymentrequested"; + public const string VoidFederatedPaymentBlock = "Payments.block.voidfederatedpayment"; + public const string VoidCancelOrderFederatedPaymentBlock = "Payments.block.voidcancelorderfederatedpayment"; + public const string RefundFederatedPaymentBlock = "Payments.block.refundfederatedpayment"; + public const string VoidOnHoldOrderFederatedPaymentBlock = "Payments.block.voidonholdorderfederatedpayment"; + public const string ValidateSettlementBlock = "Payments.block.validatesettlement"; + } + } + } +} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/CreateFederatedPaymentBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/CreateFederatedPaymentBlock.cs similarity index 73% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/CreateFederatedPaymentBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/CreateFederatedPaymentBlock.cs index 1e1fbb22..08d5fc3e 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/CreateFederatedPaymentBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/CreateFederatedPaymentBlock.cs @@ -1,41 +1,21 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Linq; +using System.Threading.Tasks; +using global::Braintree; +using global::Braintree.Exceptions; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Helpers; -namespace Plugin.Sample.Payments.Braintree +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - using System; - using System.Linq; - using System.Threading.Tasks; - using global::Braintree; - using global::Braintree.Exceptions; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which creates a payment service transaction. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Orders.CartEmailArgument, Sitecore.Commerce.Plugin.Orders.CartEmailArgument, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.CreateFederatedPaymentBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.CreateFederatedPaymentBlock)] public class CreateFederatedPaymentBlock : PipelineBlock { - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// - /// A cart with federate payment component - /// public override Task Run(CartEmailArgument arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The cart can not be null"); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs similarity index 73% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs index 4a94797d..18f2d7b4 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/EnsureSettlePaymentRequestedBlock.cs @@ -1,53 +1,29 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using global::Braintree; +using global::Braintree.Exceptions; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using global::Braintree; - using global::Braintree.Exceptions; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines an ensure settle payment requested block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Orders.SalesActivity, - /// Sitecore.Commerce.Plugin.Orders.SalesActivity, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.EnsureSettlePaymentRequestedBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.EnsureSettlePaymentRequestedBlock)] public class EnsureSettlePaymentRequestedBlock : PipelineBlock { private readonly IRemoveListEntitiesPipeline _removePipeline; - /// - /// Initializes a new instance of the class. - /// - /// The remove pipeline. public EnsureSettlePaymentRequestedBlock(IRemoveListEntitiesPipeline removePipeline) { this._removePipeline = removePipeline; } - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// A cart with Federated payment info public async override Task Run(SalesActivity arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The sales activity cannot be null."); @@ -140,12 +116,6 @@ public async override Task Run(SalesActivity arg, CommercePipelin return arg; } - /// - /// Moves to problem list. - /// - /// The sales activity. - /// The context. - /// protected async virtual Task MoveToProblemList(SalesActivity salesActivity, CommercePipelineExecutionContext context) { var transientMemberships = salesActivity.GetComponent(); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/GetClientTokenBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/GetClientTokenBlock.cs similarity index 74% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/GetClientTokenBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/GetClientTokenBlock.cs index a19ace7c..bf1df763 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/GetClientTokenBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/GetClientTokenBlock.cs @@ -1,28 +1,14 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Braintree; using Braintree.Exceptions; using Sitecore.Commerce.Core; using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies; -namespace Plugin.Sample.Payments.Braintree +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - /// - /// Defines a block which gets a payment service client tokent. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.GetClientTokenBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.GetClientTokenBlock)] public class GetClientTokenBlock : PipelineBlock { /// diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/RefundFederatedPaymentBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/RefundFederatedPaymentBlock.cs similarity index 78% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/RefundFederatedPaymentBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/RefundFederatedPaymentBlock.cs index b9e7596d..362a64f9 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/RefundFederatedPaymentBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/RefundFederatedPaymentBlock.cs @@ -1,56 +1,30 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using global::Braintree; +using global::Braintree.Exceptions; +using Microsoft.Extensions.Logging; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using global::Braintree; - using global::Braintree.Exceptions; - using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a refind federated paymentBlock. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Payments.OrderPaymentsArgument, - /// Sitecore.Commerce.Plugin.Payments.OrderPaymentsArgument, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.RefundFederatedPaymentBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.RefundFederatedPaymentBlock)] public class RefundFederatedPaymentBlock : PipelineBlock { private readonly IPersistEntityPipeline _persistPipeline; - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. public RefundFederatedPaymentBlock(IPersistEntityPipeline persistEntityPipeline) { this._persistPipeline = persistEntityPipeline; } - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// - /// An OrderPaymentsArgument with order and Federated payment info - /// public async override Task Run(OrderPaymentsArgument arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull("The arg can not be null"); @@ -166,12 +140,6 @@ public async override Task Run(OrderPaymentsArgument arg, return arg; } - /// - /// Generates the sales activity. - /// - /// The order. - /// The payment. - /// The context. protected async virtual Task GenerateSalesActivity(Order order, PaymentComponent payment, CommercePipelineExecutionContext context) { var salesActivity = new SalesActivity diff --git a/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs new file mode 100644 index 00000000..69d95820 --- /dev/null +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs @@ -0,0 +1,46 @@ +using System.Threading.Tasks; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks +{ + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.UpdateFederatedPaymentAfterSettlementBlock)] + public class UpdateFederatedPaymentAfterSettlementBlock : PipelineBlock + { + private readonly GetOrderCommand _getOrderCommand; + private readonly IPersistEntityPipeline _persistEntityPipeline; + + public UpdateFederatedPaymentAfterSettlementBlock(GetOrderCommand getOrderCommand, IPersistEntityPipeline persistEntityPipeline) + { + this._getOrderCommand = getOrderCommand; + this._persistEntityPipeline = persistEntityPipeline; + } + + public async override Task Run(SalesActivity arg, CommercePipelineExecutionContext context) + { + Condition.Requires(arg).IsNotNull($"{this.Name}: sales activity can not be null."); + if (!arg.HasComponent()) + { + return arg; + } + + var order = await this._getOrderCommand.Process(context.CommerceContext, arg.Order.EntityTarget); + + if (order == null || !order.HasComponent()) + { + return arg; + } + + var orderPayment = order.GetComponent(); + + var payment = arg.GetComponent(); + orderPayment.TransactionStatus = payment.TransactionStatus; + + await this._persistEntityPipeline.Run(new PersistEntityArgument(order), context); + return arg; + } + } +} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs similarity index 82% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs index 5a87cef4..faea739d 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/UpdateFederatedPaymentBlock.cs @@ -1,56 +1,32 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using global::Braintree; +using global::Braintree.Exceptions; +using Microsoft.Extensions.Logging; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Carts; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Helpers; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using global::Braintree; - using global::Braintree.Exceptions; - using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which updates transaction Id for an order. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Orders.Order, Sitecore.Commerce.Plugin.Orders.Order, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.UpdateFederatedPaymentBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.UpdateFederatedPaymentBlock)] public class UpdateFederatedPaymentBlock : PipelineBlock { private readonly IPersistEntityPipeline _persistEntityPipeline; - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. public UpdateFederatedPaymentBlock(IPersistEntityPipeline persistEntityPipeline) { this._persistEntityPipeline = persistEntityPipeline; } - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// - /// A cart with federate payment component - /// public async override Task Run(Order arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: order can not be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/ValidateSettlementBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/ValidateSettlementBlock.cs similarity index 66% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/ValidateSettlementBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/ValidateSettlementBlock.cs index 758a939a..b14cfe1e 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/ValidateSettlementBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/ValidateSettlementBlock.cs @@ -1,52 +1,27 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using global::Braintree; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; -namespace Plugin.Sample.Payments.Braintree +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using global::Braintree; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a validate settlement block. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Orders.SalesActivity, - /// Sitecore.Commerce.Plugin.Orders.SalesActivity, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.ValidateSettlementBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.ValidateSettlementBlock)] public class ValidateSettlementBlock : PipelineBlock { private readonly IRemoveListEntitiesPipeline _removePipeline; - /// - /// Initializes a new instance of the class. - /// - /// The remove pipeline. public ValidateSettlementBlock(IRemoveListEntitiesPipeline removePipeline) { this._removePipeline = removePipeline; } - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// A cart with Federated payment info public async override Task Run(SalesActivity arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The sales activity cannot be null."); diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs similarity index 70% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs index f1f2b89b..885f369a 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Pipelines/Blocks/VoidCancelOrderFederatedPaymentBlock.cs @@ -1,54 +1,30 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using global::Braintree; +using global::Braintree.Exceptions; +using Microsoft.Extensions.Logging; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Framework.Conditions; +using Sitecore.Framework.Pipelines; +using Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using global::Braintree; - using global::Braintree.Exceptions; - using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a void canceled order federated paymentBlock. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Payments.Order, - /// Sitecore.Commerce.Plugin.Payments.Order, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.VoidCancelOrderFederatedPaymentBlock)] + [PipelineDisplayName(PaymentsConstants.Pipelines.Blocks.VoidCancelOrderFederatedPaymentBlock)] public class VoidCancelOrderFederatedPaymentBlock : PipelineBlock { private readonly IPersistEntityPipeline _persistPipeline; - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. public VoidCancelOrderFederatedPaymentBlock(IPersistEntityPipeline persistEntityPipeline) { this._persistPipeline = persistEntityPipeline; } - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// An order with Federated payment info public async override Task Run(Order arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull("The arg can not be null"); @@ -116,13 +92,6 @@ public async override Task Run(Order arg, CommercePipelineExecutionContex return arg; } - /// - /// Generates the sales activity. - /// - /// The order. - /// The payment. - /// The context. - /// protected async virtual Task GenerateSalesActivity(Order order, PaymentComponent payment, CommercePipelineExecutionContext context) { var salesActivity = new SalesActivity diff --git a/src/Foundation/Commerce.Payments/Engine.Payments/Policies/BraintreeClientPolicy.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Policies/BraintreeClientPolicy.cs new file mode 100644 index 00000000..fd9677da --- /dev/null +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Policies/BraintreeClientPolicy.cs @@ -0,0 +1,20 @@ +using Sitecore.Commerce.Core; + +namespace Sitecore.Foundation.Commerce.Engine.Plugin.Payments.Policies +{ + public class BraintreeClientPolicy : Policy + { + public BraintreeClientPolicy() + { + this.Environment = string.Empty; + this.MerchantId = string.Empty; + this.PublicKey = string.Empty; + this.PrivateKey = string.Empty; + } + + public string Environment { get; set; } + public string MerchantId { get; set; } + public string PublicKey { get; set; } + public string PrivateKey { get; set; } + } +} diff --git a/src/Foundation/Commerce/Engine/Plugin/code/Properties/AssemblyInfo.cs b/src/Foundation/Commerce.Payments/Engine.Payments/Properties/AssemblyInfo.cs similarity index 83% rename from src/Foundation/Commerce/Engine/Plugin/code/Properties/AssemblyInfo.cs rename to src/Foundation/Commerce.Payments/Engine.Payments/Properties/AssemblyInfo.cs index 161b8590..81a25cff 100644 --- a/src/Foundation/Commerce/Engine/Plugin/code/Properties/AssemblyInfo.cs +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ // associated with an assembly. [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Code")] +[assembly: AssemblyProduct("Sitecore.Foundation.Commerce.Engine.Plugin.Payments")] [assembly: AssemblyTrademark("")] // Setting ComVisible to false makes the types in this assembly not visible @@ -16,4 +16,4 @@ [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("16a75548-b717-41d9-a55a-d1e68765e530")] +[assembly: Guid("7ac44b7f-641e-4284-a182-c962e5d56c3f")] diff --git a/src/Foundation/Commerce/Engine/Plugin/code/Sitecore.Foundation.Commerce.Engine.Plugin.Habitat.xproj b/src/Foundation/Commerce.Payments/Engine.Payments/Sitecore.Foundation.Commerce.Engine.Plugin.Payments.xproj similarity index 86% rename from src/Foundation/Commerce/Engine/Plugin/code/Sitecore.Foundation.Commerce.Engine.Plugin.Habitat.xproj rename to src/Foundation/Commerce.Payments/Engine.Payments/Sitecore.Foundation.Commerce.Engine.Plugin.Payments.xproj index 0ff128f4..2c15b02c 100644 --- a/src/Foundation/Commerce/Engine/Plugin/code/Sitecore.Foundation.Commerce.Engine.Plugin.Habitat.xproj +++ b/src/Foundation/Commerce.Payments/Engine.Payments/Sitecore.Foundation.Commerce.Engine.Plugin.Payments.xproj @@ -6,8 +6,8 @@ - 16a75548-b717-41d9-a55a-d1e68765e530 - Sitecore.Foundation.Commerce.Engine.Plugin.Habitat + 7ac44b7f-641e-4284-a182-c962e5d56c3f + Sitecore.Foundation.Commerce.Engine.Plugin.Payments .\obj .\bin\ v4.5.2 diff --git a/src/Foundation/Commerce.Payments/Engine.Payments/project.json b/src/Foundation/Commerce.Payments/Engine.Payments/project.json new file mode 100644 index 00000000..17853317 --- /dev/null +++ b/src/Foundation/Commerce.Payments/Engine.Payments/project.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Braintree": "3.6.0", + "Sitecore.Commerce.Core": "1.0.2301", + "Sitecore.Commerce.Plugin.Orders": "1.0.2301", + "Sitecore.Commerce.Plugin.Payments": "1.0.2301" + }, + + "frameworks": { + "net452": { + } + } +} diff --git a/src/Foundation/Commerce/Engine/App_ConfigureSitecore/CartPipelineExtentions.cs b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/CartPipelineExtentions.cs new file mode 100644 index 00000000..86623d09 --- /dev/null +++ b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/CartPipelineExtentions.cs @@ -0,0 +1,43 @@ +using Microsoft.Extensions.DependencyInjection; + +using Sitecore.Commerce.Plugin.Carts; +using Sitecore.Commerce.Plugin.Catalog.Cs; +using Sitecore.Commerce.Plugin.Coupons; +using Sitecore.Commerce.Plugin.Fulfillment; +using Sitecore.Commerce.Plugin.Payments; +using Sitecore.Commerce.Plugin.Promotions; +using Sitecore.Commerce.Plugin.Tax; +using Sitecore.Framework.Pipelines.Definitions.Extensions; + +namespace Sitecore.Foundation.Commerce.Engine.App_ConfigureSitecore +{ + public static class CartPipelineExtentions + { + public static IServiceCollection ConfigureCartPipelines(this IServiceCollection services) + { + services.Sitecore().Pipelines(config => config + .ConfigurePipeline(builder => builder + .Add() + .Add() + .Add() + .Add() + .Add() + .Add() + .Add() + .Add() + .Add()) + + .ConfigurePipeline(builder => builder + .Add() + .Add() + .Add() + .Add() + .Add() + .Add()) + + .ConfigurePipeline(builder => builder.Add().After())); + + return services; + } + } +} diff --git a/src/Foundation/Commerce/Engine/App_ConfigureSitecore/InitializeEnvironmentPipelineExtentions.cs b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/InitializeEnvironmentPipelineExtentions.cs new file mode 100644 index 00000000..931e560e --- /dev/null +++ b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/InitializeEnvironmentPipelineExtentions.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.DependencyInjection; + +using Sitecore.Commerce.Core; +using Sitecore.Framework.Pipelines.Definitions.Extensions; +using Sitecore.Foundation.Commerce.Engine.Pipelines.Blocks; + +namespace Sitecore.Foundation.Commerce.Engine.App_ConfigureSitecore +{ + public static class InitializeEnvironmentPipelineExtentions + { + public static IServiceCollection ConfigureInitializeEnvironmentPipeline(this IServiceCollection services) + { + services.Sitecore().Pipelines(config => config + + .ConfigurePipeline(builder => builder + .Add() + ) + + ); + + return services; + } + } +} diff --git a/src/Foundation/Commerce/Engine/App_ConfigureSitecore/OrdersPipelinesExtentions.cs b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/OrdersPipelinesExtentions.cs new file mode 100644 index 00000000..6c0cf8ff --- /dev/null +++ b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/OrdersPipelinesExtentions.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.DependencyInjection; + +using Sitecore.Commerce.Plugin.Inventory.Cs; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Framework.Pipelines.Definitions.Extensions; + +namespace Sitecore.Foundation.Commerce.Engine.App_ConfigureSitecore +{ + public static class OrdersPipelinesExtentions + { + public static IServiceCollection ConfigureOrdersPipelines(this IServiceCollection services) + { + services.Sitecore().Pipelines(config => config + .ConfigurePipeline(builder => builder + .Add())); + + //.ConfigurePipeline(builder => builder.Add())); + + return services; + } + } +} diff --git a/src/Foundation/Commerce/Engine/App_ConfigureSitecore/RunningPluginsPipelineExtentions.cs b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/RunningPluginsPipelineExtentions.cs new file mode 100644 index 00000000..b1ac670b --- /dev/null +++ b/src/Foundation/Commerce/Engine/App_ConfigureSitecore/RunningPluginsPipelineExtentions.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.DependencyInjection; + +using Sitecore.Commerce.Core; +using Sitecore.Framework.Pipelines.Definitions.Extensions; +using Sitecore.Foundation.Commerce.Engine.Pipelines.Blocks; + +namespace Sitecore.Foundation.Commerce.Engine.App_ConfigureSitecore +{ + public static class RunningPluginsPipelineExtentions + { + public static IServiceCollection ConfigureRunningPluginsPipeline(this IServiceCollection services) + { + services.Sitecore().Pipelines(config => config + + .ConfigurePipeline(c => + { + c.Add().After(); + }) + + ); + + return services; + } + } +} diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigApplicationInsights.cs b/src/Foundation/Commerce/Engine/App_Startup/ApplicationInsightsExtentions.cs similarity index 67% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigApplicationInsights.cs rename to src/Foundation/Commerce/Engine/App_Startup/ApplicationInsightsExtentions.cs index 2144a57f..b6436ba2 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigApplicationInsights.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/ApplicationInsightsExtentions.cs @@ -3,11 +3,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigApplicationInsights + public static class ApplicationInsightsExtentions { - public static void Register(IConfigurationRoot configuration, IServiceCollection services) + public static IServiceCollection ConfigureApplicationInsights(this IServiceCollection services, IConfigurationRoot configuration) { // TODO uncomment for Application Insights services.AddApplicationInsightsTelemetry(configuration); @@ -16,6 +16,8 @@ public static void Register(IConfigurationRoot configuration, IServiceCollection // TODO uncomment for Application Insights services.Add(new ServiceDescriptor(typeof(TelemetryClient), typeof(TelemetryClient), ServiceLifetime.Singleton)); + + return services; } } } diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigEnvironment.cs b/src/Foundation/Commerce/Engine/App_Startup/CommerceEnvironmentExtentions.cs similarity index 58% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigEnvironment.cs rename to src/Foundation/Commerce/Engine/App_Startup/CommerceEnvironmentExtentions.cs index 9c399629..a4d473d0 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigEnvironment.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/CommerceEnvironmentExtentions.cs @@ -4,15 +4,11 @@ using Sitecore.Commerce.Core; using Sitecore.Commerce.Provider.FileSystem; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigEnvironment + public static class CommerceEnvironmentExtentions { - /// - /// Gets the global environment. - /// - /// A - public static CommerceEnvironment Register(IConfigurationRoot configuration, NodeContext node, IServiceCollection services) + public static CommerceEnvironment ConfigureCommerceEnvironment(this IServiceCollection services, IConfigurationRoot configuration, NodeContext node) { var logger = ApplicationLogging.CreateLogger("ConfigEnvironment"); @@ -33,5 +29,15 @@ public static CommerceEnvironment Register(IConfigurationRoot configuration, Nod return environment; } + + public static void Start (this IStartEnvironmentPipeline startEnvironmentPipeline, NodeContext node, IConfigurationRoot configuration) + { + // Starting the environment to register Minion policies and run Minions + var environmentName = configuration.GetSection("AppSettings:EnvironmentName").Value; + + node.AddDataMessage("EnvironmentStartup", $"StartEnvironment={environmentName}"); + + startEnvironmentPipeline.Run(environmentName, node.GetPipelineContextOptions()).Wait(); + } } } diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigNode.cs b/src/Foundation/Commerce/Engine/App_Startup/CommerceNodeExtentions.cs similarity index 74% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigNode.cs rename to src/Foundation/Commerce/Engine/App_Startup/CommerceNodeExtentions.cs index 0129f7e1..cab68944 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigNode.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/CommerceNodeExtentions.cs @@ -4,15 +4,11 @@ using Microsoft.Extensions.DependencyInjection; using Sitecore.Commerce.Core; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigNode + public static class CommerceNodeExtentions { - /// - /// Initializes the node context. - /// - /// A - public static NodeContext Initialize(string nodeInstanceId, IHostingEnvironment hostEnv) + public static NodeContext CommerceNodeInitialize(this IHostingEnvironment hostEnv, string nodeInstanceId) { var logger = ApplicationLogging.CreateLogger("ConfigNode"); @@ -33,7 +29,7 @@ public static NodeContext Initialize(string nodeInstanceId, IHostingEnvironment }; } - public static void Register(IConfigurationRoot configuration, string nodeInstanceId, CommerceEnvironment environment, NodeContext node, IServiceCollection services) + public static void ConfigureCommerceNode(this IServiceCollection services, IConfigurationRoot configuration, string nodeInstanceId, CommerceEnvironment environment, NodeContext node) { node.Environment = environment; node.GlobalEnvironmentName = environment.Name; @@ -54,5 +50,10 @@ public static void Register(IConfigurationRoot configuration, string nodeInstanc services.AddSingleton(node); } + + public static void Start (this IStartNodePipeline startNodePipeline, NodeContext node) + { + startNodePipeline.Run(node, node.GetPipelineContextOptions()).Wait(); + } } } diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigDataProtection.cs b/src/Foundation/Commerce/Engine/App_Startup/DataProtectionExtentions.cs similarity index 91% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigDataProtection.cs rename to src/Foundation/Commerce/Engine/App_Startup/DataProtectionExtentions.cs index fb98d9e1..76248a17 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigDataProtection.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/DataProtectionExtentions.cs @@ -4,15 +4,15 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigDataProtection + public static class DataProtectionExtentions { /// /// Setups the data protection storage and encryption protection type /// /// The services. - public static void Register(IConfigurationRoot configuration, IServiceCollection services) + public static void ConfigureDataProtection(this IServiceCollection services, IConfigurationRoot configuration) { var builder = services.AddDataProtection(); diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigErrorPage.cs b/src/Foundation/Commerce/Engine/App_Startup/ErrorPageExtentions.cs similarity index 66% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigErrorPage.cs rename to src/Foundation/Commerce/Engine/App_Startup/ErrorPageExtentions.cs index 6ca7ea80..d0adb7ca 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigErrorPage.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/ErrorPageExtentions.cs @@ -5,11 +5,11 @@ using System.Linq; using System.Threading.Tasks; -namespace Sitecore.Foundation.Commerce.Engine.App_Start +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigErrorPage + public static class ErrorPageExtentions { - public static void Register(IHostingEnvironment hostEnv, IApplicationBuilder app) + public static void ConfigureErrorPage(this IApplicationBuilder app, IHostingEnvironment hostEnv) { if (hostEnv.IsDevelopment()) { diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigLogging.cs b/src/Foundation/Commerce/Engine/App_Startup/LoggingExtentions.cs similarity index 91% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigLogging.cs rename to src/Foundation/Commerce/Engine/App_Startup/LoggingExtentions.cs index 7db00a38..a99d8e45 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigLogging.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/LoggingExtentions.cs @@ -5,11 +5,11 @@ using Serilog; using Sitecore.Commerce.Core; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigLogging + public static class LoggingExtentions { - public static void Register(IHostingEnvironment hostEnv, ILoggerFactory loggerFactory, string nodeInstanceId) + public static void ConfigureLogging(this ILoggerFactory loggerFactory, IHostingEnvironment hostEnv, string nodeInstanceId) { // Set the primary LoggerFactory to use everywhere ApplicationLogging.LoggerFactory = loggerFactory; diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigOData.cs b/src/Foundation/Commerce/Engine/App_Startup/ODataExtentions.cs similarity index 81% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigOData.cs rename to src/Foundation/Commerce/Engine/App_Startup/ODataExtentions.cs index 4fa4791d..07a32910 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigOData.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/ODataExtentions.cs @@ -4,11 +4,11 @@ using Microsoft.AspNetCore.OData.Routing; using Sitecore.Commerce.Core; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigOData + public static class ODataExtentions { - public static void Register(IApplicationBuilder app, IConfigureServiceApiPipeline contextPipeline, IConfigureOpsServiceApiPipeline contextOpsServiceApiPipeline, NodeContext node) + public static void ConfigureOData(this IApplicationBuilder app, IConfigureServiceApiPipeline contextPipeline, IConfigureOpsServiceApiPipeline contextOpsServiceApiPipeline, NodeContext node) { // Initialize plugins OData contexts app.InitializeODataBuilder(); diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigSettings.cs b/src/Foundation/Commerce/Engine/App_Startup/SettingsExtentions.cs similarity index 76% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigSettings.cs rename to src/Foundation/Commerce/Engine/App_Startup/SettingsExtentions.cs index dcf4a2b9..b69d3223 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigSettings.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/SettingsExtentions.cs @@ -2,11 +2,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigSettings + public static class SettingsExtentions { - public static IConfigurationRoot Register(IHostingEnvironment hostEnv) + public static IConfigurationRoot ConfigureSettings(this IHostingEnvironment hostEnv) { // Setup configuration sources. var builder = new ConfigurationBuilder() diff --git a/src/Foundation/Commerce/Engine/code/App_Start/ConfigSitecore.cs b/src/Foundation/Commerce/Engine/App_Startup/SitecoreExtentions.cs similarity index 83% rename from src/Foundation/Commerce/Engine/code/App_Start/ConfigSitecore.cs rename to src/Foundation/Commerce/Engine/App_Startup/SitecoreExtentions.cs index d584236f..101de3a7 100644 --- a/src/Foundation/Commerce/Engine/code/App_Start/ConfigSitecore.cs +++ b/src/Foundation/Commerce/Engine/App_Startup/SitecoreExtentions.cs @@ -3,11 +3,11 @@ using Microsoft.Extensions.Logging; using Sitecore.Framework.Rules; -namespace Sitecore.Foundation.Commerce.Engine +namespace Sitecore.Foundation.Commerce.Engine.App_Startup { - public static class ConfigSitecore + public static class SitecoreExtentions { - public static void Register(IServiceProvider hostServices, IServiceCollection services) + public static void ConfigureSitecore(this IServiceCollection services, IServiceProvider hostServices) { var logger = ApplicationLogging.CreateLogger("ConfigSitecore"); diff --git a/src/Foundation/Commerce/Engine/code/ApplicationLogging.cs b/src/Foundation/Commerce/Engine/ApplicationLogging.cs similarity index 100% rename from src/Foundation/Commerce/Engine/code/ApplicationLogging.cs rename to src/Foundation/Commerce/Engine/ApplicationLogging.cs diff --git a/src/Foundation/Commerce/Engine/CommerceEngineConstants.cs b/src/Foundation/Commerce/Engine/CommerceEngineConstants.cs new file mode 100644 index 00000000..d9decb50 --- /dev/null +++ b/src/Foundation/Commerce/Engine/CommerceEngineConstants.cs @@ -0,0 +1,17 @@ +namespace Sitecore.Foundation.Commerce.Engine +{ + /// + /// The adventure works constants. + /// + public static class CommerceEngineConstants + { + public static class Pipelines + { + public static class Blocks + { + public const string RegisteredPluginBlock = "CommerceEngine.block.RegisteredPlugin"; + public const string BootstrapManagedListsBlock = "CommerceEngine.block.BootstrapManagedLists"; + } + } + } +} diff --git a/src/Foundation/Commerce/Engine/ConfigureSitecore.cs b/src/Foundation/Commerce/Engine/ConfigureSitecore.cs new file mode 100644 index 00000000..71d6372b --- /dev/null +++ b/src/Foundation/Commerce/Engine/ConfigureSitecore.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.DependencyInjection; +using Sitecore.Commerce.Core; +using Sitecore.Foundation.Commerce.Engine.App_ConfigureSitecore; +using Sitecore.Framework.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +namespace Sitecore.Foundation.Commerce.Engine +{ + public class ConfigureSitecore : IConfigureSitecore + { + public void ConfigureServices(IServiceCollection services) + { + var assembly = Assembly.GetExecutingAssembly(); + + services.RegisterAllPipelineBlocks(assembly); + services.ConfigureInitializeEnvironmentPipeline(); + services.ConfigureRunningPluginsPipeline(); + //services.ConfigureCartPipelines(); + //services.ConfigureOrdersPipelines(); + } + } +} diff --git a/src/Foundation/Commerce/Engine/code/DiagnosticsExtensions.cs b/src/Foundation/Commerce/Engine/DiagnosticsExtensions.cs similarity index 66% rename from src/Foundation/Commerce/Engine/code/DiagnosticsExtensions.cs rename to src/Foundation/Commerce/Engine/DiagnosticsExtensions.cs index e8ccda3c..d76c3b9c 100644 --- a/src/Foundation/Commerce/Engine/code/DiagnosticsExtensions.cs +++ b/src/Foundation/Commerce/Engine/DiagnosticsExtensions.cs @@ -5,11 +5,6 @@ namespace Sitecore.Foundation.Commerce.Engine { public static class DiagnosticsExtensions { - /// - /// Adds the services diagnostics. - /// - /// The builder. - /// A public static ISitecoreServicesConfiguration AddServicesDiagnostics(this ISitecoreServicesConfiguration builder) { builder.Services.AddSitecoreServicesDiagnosticsPage(); diff --git a/src/Foundation/Commerce/Engine/Pipelines/Blocks/BootstrapManagedListsBlock.cs b/src/Foundation/Commerce/Engine/Pipelines/Blocks/BootstrapManagedListsBlock.cs new file mode 100644 index 00000000..fdf5669e --- /dev/null +++ b/src/Foundation/Commerce/Engine/Pipelines/Blocks/BootstrapManagedListsBlock.cs @@ -0,0 +1,37 @@ +using System.Threading.Tasks; + +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Orders; +using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Plugin.ManagedLists; + +namespace Sitecore.Foundation.Commerce.Engine.Pipelines.Blocks +{ + [PipelineDisplayName(CommerceEngineConstants.Pipelines.Blocks.BootstrapManagedListsBlock)] + public class BootstrapManagedListsBlock : PipelineBlock + { + private readonly CreateManagedListCommand _createManagedListCommand; + private readonly GetManagedListCommand _getManagedListCommand; + + public BootstrapManagedListsBlock( + CreateManagedListCommand createManagedList, + GetManagedListCommand getManagedListCommand) + { + this._createManagedListCommand = createManagedList; + this._getManagedListCommand = getManagedListCommand; + } + + public override async Task Run(string arg, CommercePipelineExecutionContext context) + { + var pendingOrdersListName = context.GetPolicy().PendingOrders; + var managedList = await this._getManagedListCommand.Process(context.CommerceContext, pendingOrdersListName); + if (managedList != null) + { + return arg; + } + + await this._createManagedListCommand.Process(context.CommerceContext, pendingOrdersListName); + return arg; + } + } +} diff --git a/src/Foundation/Commerce/Engine/Pipelines/Blocks/RegisteredPluginBlock.cs b/src/Foundation/Commerce/Engine/Pipelines/Blocks/RegisteredPluginBlock.cs new file mode 100644 index 00000000..c85a424c --- /dev/null +++ b/src/Foundation/Commerce/Engine/Pipelines/Blocks/RegisteredPluginBlock.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Sitecore.Commerce.Core; +using Sitecore.Framework.Pipelines; + +namespace Sitecore.Foundation.Commerce.Engine.Pipelines.Blocks +{ + [PipelineDisplayName(CommerceEngineConstants.Pipelines.Blocks.RegisteredPluginBlock)] + public class RegisteredPluginBlock : PipelineBlock, IEnumerable, CommercePipelineExecutionContext> + { + public override Task> Run(IEnumerable arg, CommercePipelineExecutionContext context) + { + if (arg == null) + { + return Task.FromResult(arg); + } + + var plugins = arg.ToList(); + PluginHelper.RegisterPlugin(this, plugins); + + return Task.FromResult(plugins.AsEnumerable()); + } + } +} diff --git a/src/Foundation/Commerce/Engine/Plugin/code/Class1.cs b/src/Foundation/Commerce/Engine/Plugin/code/Class1.cs deleted file mode 100644 index 91f41125..00000000 --- a/src/Foundation/Commerce/Engine/Plugin/code/Class1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Code -{ - public class Class1 - { - public Class1() - { - } - } -} diff --git a/src/Foundation/Commerce/Engine/Plugin/code/project.json b/src/Foundation/Commerce/Engine/Plugin/code/project.json deleted file mode 100644 index dead0452..00000000 --- a/src/Foundation/Commerce/Engine/Plugin/code/project.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - "frameworks": { - "netstandard1.6": { - "imports": "dnxcore50" - } - }, - "configurations": { - "Demo-Retail": {} - } -} diff --git a/src/Foundation/Commerce/Engine/code/Program.cs b/src/Foundation/Commerce/Engine/Program.cs similarity index 100% rename from src/Foundation/Commerce/Engine/code/Program.cs rename to src/Foundation/Commerce/Engine/Program.cs diff --git a/src/Foundation/Commerce/Engine/code/Properties/launchSettings.json b/src/Foundation/Commerce/Engine/Properties/launchSettings.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/Properties/launchSettings.json rename to src/Foundation/Commerce/Engine/Properties/launchSettings.json diff --git a/src/Foundation/Commerce/Engine/code/Sitecore.Foundation.Commerce.Engine.xproj b/src/Foundation/Commerce/Engine/Sitecore.Foundation.Commerce.Engine.xproj similarity index 100% rename from src/Foundation/Commerce/Engine/code/Sitecore.Foundation.Commerce.Engine.xproj rename to src/Foundation/Commerce/Engine/Sitecore.Foundation.Commerce.Engine.xproj diff --git a/src/Foundation/Commerce/Engine/Startup.cs b/src/Foundation/Commerce/Engine/Startup.cs new file mode 100644 index 00000000..a9451587 --- /dev/null +++ b/src/Foundation/Commerce/Engine/Startup.cs @@ -0,0 +1,72 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.OData.Extensions; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Sitecore.Commerce.Core; +using Sitecore.Framework.Diagnostics; +using Sitecore.Foundation.Commerce.Engine.App_Startup; + +namespace Sitecore.Foundation.Commerce.Engine +{ + public class Startup + { + private readonly ILogger _logger; + + private readonly IHostingEnvironment _hostEnv; + private readonly IServiceProvider _hostServices; + private readonly IConfigurationRoot _configuration; + private readonly string _nodeInstanceId = Guid.NewGuid().ToString("N"); + + private NodeContext _node; + + public Startup(IServiceProvider serviceProvider, IHostingEnvironment hostEnv, ILoggerFactory loggerFactory) + { + this._hostEnv = hostEnv; + this._hostServices = serviceProvider; + + loggerFactory.ConfigureLogging(hostEnv, _nodeInstanceId); + this._logger = ApplicationLogging.CreateLogger("Startup"); + + this._configuration = _hostEnv.ConfigureSettings(); + } + + public void ConfigureServices(IServiceCollection services) + { + services.ConfigureDataProtection(_configuration); + + _node = _hostEnv.CommerceNodeInitialize(_nodeInstanceId); + var environment = services.ConfigureCommerceEnvironment(_configuration, _node); + + services.ConfigureCommerceNode(_configuration, _nodeInstanceId, environment, _node); + services.AddOData(); + services.AddMvc(); + services.ConfigureApplicationInsights(_configuration); + services.ConfigureSitecore(_hostServices); + + services.AddSingleton(this._logger); + } + + public void Configure( + IApplicationBuilder app, + IConfigureServiceApiPipeline contextPipeline, + IStartNodePipeline startNodePipeline, + IConfigureOpsServiceApiPipeline contextOpsServiceApiPipeline, + IStartEnvironmentPipeline startEnvironmentPipeline, + ILoggerFactory loggerFactory) + { + app.UseApplicationInsightsRequestTelemetry(); + app.UseApplicationInsightsExceptionTelemetry(); + app.UseDiagnostics(); + app.UseStaticFiles(); + app.ConfigureErrorPage(_hostEnv); + + startNodePipeline.Start(this._node); + startEnvironmentPipeline.Start(this._node, this._configuration); + + app.ConfigureOData(contextPipeline, contextOpsServiceApiPipeline, _node); + } + } +} diff --git a/src/Foundation/Commerce/Engine/code/App_Start/Startup.cs b/src/Foundation/Commerce/Engine/code/App_Start/Startup.cs deleted file mode 100644 index eb6795c1..00000000 --- a/src/Foundation/Commerce/Engine/code/App_Start/Startup.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.OData.Extensions; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Sitecore.Commerce.Core; -using Sitecore.Foundation.Commerce.Engine.App_Start; -using Sitecore.Framework.Diagnostics; - -namespace Sitecore.Foundation.Commerce.Engine -{ - public class Startup - { - private readonly ILogger _logger; - - private readonly IHostingEnvironment _hostEnv; - private readonly IServiceProvider _hostServices; - private readonly IConfigurationRoot _configuration; - private readonly string _nodeInstanceId = Guid.NewGuid().ToString("N"); - - private NodeContext _node; - - /// - /// Initializess a new instance of the class. - /// - /// The service provider. - /// The host env. - /// The logger factory. - public Startup(IServiceProvider serviceProvider, IHostingEnvironment hostEnv, ILoggerFactory loggerFactory) - { - this._hostEnv = hostEnv; - this._hostServices = serviceProvider; - - ConfigLogging.Register(hostEnv, loggerFactory, _nodeInstanceId); - this._logger = ApplicationLogging.CreateLogger("Startup"); - - this._configuration = ConfigSettings.Register(_hostEnv); - } - - /// - /// Configures the services. - /// - /// The services. - public void ConfigureServices(IServiceCollection services) - { - ConfigDataProtection.Register(_configuration, services); - - _node = ConfigNode.Initialize(_nodeInstanceId, _hostEnv); - var environment = ConfigEnvironment.Register(_configuration, _node, services); - - ConfigNode.Register(_configuration, _nodeInstanceId, environment, _node, services); - - services.AddOData(); - services.AddMvc(); - - ConfigApplicationInsights.Register(_configuration, services); - ConfigSitecore.Register(_hostServices, services); - - services.AddSingleton(this._logger); - } - - /// - /// Configures the specified application. - /// - /// The application. - /// The context pipeline. - /// The start node pipeline. - /// The API pipeline. - /// The start environment pipeline. - /// The logger factory. - public void Configure( - IApplicationBuilder app, - IConfigureServiceApiPipeline contextPipeline, - IStartNodePipeline startNodePipeline, - IConfigureOpsServiceApiPipeline contextOpsServiceApiPipeline, - IStartEnvironmentPipeline startEnvironmentPipeline, - ILoggerFactory loggerFactory) - { - app.UseApplicationInsightsRequestTelemetry(); - app.UseApplicationInsightsExceptionTelemetry(); - app.UseDiagnostics(); - app.UseStaticFiles(); - - ConfigErrorPage.Register(_hostEnv, app); - - startNodePipeline.Run(this._node, this._node.GetPipelineContextOptions()).Wait(); - - ConfigOData.Register(app, contextPipeline, contextOpsServiceApiPipeline, _node); - } - } -} diff --git a/src/Foundation/Commerce/Engine/code/Startup.cs b/src/Foundation/Commerce/Engine/code/Startup.cs deleted file mode 100644 index 064c6a2e..00000000 --- a/src/Foundation/Commerce/Engine/code/Startup.cs +++ /dev/null @@ -1,368 +0,0 @@ - - -//TODO: THis is from the referece storefront. Remove when validated refactoring - - -//using System; -//using System.IO; - -//using Microsoft.ApplicationInsights; -//using Microsoft.ApplicationInsights.Extensibility; -//using Microsoft.AspNetCore.Builder; -//using Microsoft.AspNetCore.DataProtection; -//using Microsoft.AspNetCore.DataProtection.XmlEncryption; -//using Microsoft.AspNetCore.Hosting; -//using Microsoft.AspNetCore.OData.Builder; -//using Microsoft.AspNetCore.OData.Extensions; -//using Microsoft.AspNetCore.OData.Routing; -//using Microsoft.Extensions.Configuration; -//using Microsoft.Extensions.DependencyInjection; -//using Microsoft.Extensions.Logging; - -//using Serilog; - -//using Sitecore.Commerce.Core; -//using Sitecore.Commerce.Provider.FileSystem; -//using Sitecore.Framework.Diagnostics; -//using Sitecore.Framework.Rules; - -//namespace Sitecore.Foundation.Commerce.Engine -//{ -// public class Startup -// { -// private string _nodeInstanceId = Guid.NewGuid().ToString("N"); -// private readonly IServiceProvider _hostServices; -// private readonly IHostingEnvironment _hostEnv; -// private readonly IConfiguration _configuration; -// private volatile CommerceEnvironment _environment; -// private readonly Microsoft.Extensions.Logging.ILogger _logger; -// private volatile NodeContext _nodeContext; -// private IServiceCollection _services; - -// /// -// /// Initializes a new instance of the class. -// /// -// /// The service provider. -// /// The host env. -// /// The logger factory. -// public Startup(IServiceProvider serviceProvider, IHostingEnvironment hostEnv, ILoggerFactory loggerFactory) -// { -// this._hostEnv = hostEnv; -// this._hostServices = serviceProvider; - -// // Setup logging -// var logsPath = Path.Combine(this._hostEnv.WebRootPath, "logs"); - -// var loggingConfig = new LoggerConfiguration() -// .Enrich.With(new ScLogEnricher()) -// .MinimumLevel.Information(); // leave all filtering to the MS provider - -// if (this._hostEnv.IsDevelopment()) -// { -// loggingConfig.WriteTo.LiterateConsole(Serilog.Events.LogEventLevel.Information); -// loggingConfig.WriteTo.RollingFile($@"{logsPath}\SCF.{DateTimeOffset.UtcNow:yyyyMMdd}.log.{this._nodeInstanceId}.txt", Serilog.Events.LogEventLevel.Information, "{ThreadId} {Timestamp:HH:mm:ss} {ScLevel} {Message}{NewLine}{Exception}"); - -// } -// else if (this._hostEnv.IsProduction()) -// { -// //// Uncomment if you want to log into Mongo -// ////.WriteTo.MongoDBCapped("mongodb://localhost/logs", collectionName: "SitecoreCommerce") -// loggingConfig.WriteTo.RollingFile($@"{logsPath}\SCF.{DateTimeOffset.UtcNow:yyyyMMdd}.log.{this._nodeInstanceId}.txt", Serilog.Events.LogEventLevel.Warning, "{ThreadId} {Timestamp:HH:mm:ss} {ScLevel} {Message}{NewLine}{Exception}"); -// } -// else if (this._hostEnv.IsEnvironment("load")) -// { -// //// Uncomment if you want to log into Mongo -// ////.WriteTo.MongoDBCapped("mongodb://localhost/logs", collectionName: "SitecoreCommerce") -// loggingConfig.WriteTo.RollingFile($@"{logsPath}\SCF.{DateTimeOffset.UtcNow:yyyyMMdd}.log.{this._nodeInstanceId}.txt", Serilog.Events.LogEventLevel.Warning, "{ThreadId} {Timestamp:HH:mm:ss} {ScLevel} {Message}{NewLine}{Exception}"); -// } - -// var logger = loggingConfig.CreateLogger(); -// loggerFactory -// .WithFilter(new FilterLoggerSettings -// { -// { "Microsoft", LogLevel.Warning }, -// { "System", LogLevel.Warning }, - -// }) -// .AddSerilog(logger); - -// ////loggerFactory.AddConsole(LogLevel.Error, true); -// this._logger = loggerFactory.CreateLogger("Startup"); - -// // Setup configuration sources. -// var builder = new ConfigurationBuilder() -// .SetBasePath(hostEnv.WebRootPath) -// .AddJsonFile("config.json") -// .AddEnvironmentVariables(); - -// this._configuration = builder.Build(); - -// // TODO uncomment for Application Insights -// if (this._hostEnv.IsDevelopment()) -// { -// builder.AddApplicationInsightsSettings(developerMode: true); -// } -// } - -// /// -// /// Gets the node context. -// /// -// /// -// /// The node context. -// /// -// public NodeContext NodeContext => this._nodeContext ?? this.InitializeNodeContext(); - -// /// -// /// Gets or sets the Initial Startup Environment. This will tell the Node how to behave -// /// This will be overloaded by the Environment stored in configuration. -// /// -// /// -// /// The startup environment. -// /// -// public CommerceEnvironment StartupEnvironment -// { -// get -// { -// return this._environment ?? (this._environment = new CommerceEnvironment { Name = "Bootstrap" }); -// } - -// set -// { -// this._environment = value; -// } -// } - -// /// -// /// Configures the services. -// /// -// /// The services. -// public void ConfigureServices(IServiceCollection services) -// { -// this._services = services; - -// this.SetupDataProtection(services); - -// this.StartupEnvironment = this.GetGlobalEnvironment(); -// this.NodeContext.Environment = this.StartupEnvironment; - -// this._services.AddSingleton(this.StartupEnvironment); -// this._services.AddSingleton(this.NodeContext); - -// // Add the ODataServiceBuilder to the services collection -// services.AddOData(); - -// // Add MVC services to the services container. -// services.AddMvc(); - -// // TODO uncomment for Application Insights -// services.AddApplicationInsightsTelemetry(this._configuration); - -// TelemetryConfiguration.Active.DisableTelemetry = true; - -// this._logger.LogInformation("BootStrapping Services..."); - -// services.Sitecore() -// .Eventing() -// //// .Bootstrap(this._hostServices) -// //// .AddServicesDiagnostics() -// .Caching(config => config -// .AddMemoryStore("GlobalEnvironment") -// .ConfigureCaches("GlobalEnvironment.*", "GlobalEnvironment")) -// //// .AddCacheDiagnostics() -// .Rules(config => config -// .IgnoreNamespaces(n => n.Equals("Sitecore.Commerce.Plugin.Tax"))) -// .RulesSerialization(); -// services.Add(new ServiceDescriptor(typeof(IRuleBuilderInit), typeof(RuleBuilder), ServiceLifetime.Transient)); - -// this._logger.LogInformation("BootStrapping application..."); -// services.Sitecore().Bootstrap(this._hostServices); - -// // TODO uncomment for Application Insights -// services.Add(new ServiceDescriptor(typeof(TelemetryClient), typeof(TelemetryClient), ServiceLifetime.Singleton)); -// this.NodeContext.Objects.Add(services); - -// services.AddSingleton(this._logger); -// } - -// /// -// /// Configures the specified application. -// /// -// /// The application. -// /// The context pipeline. -// /// The start node pipeline. -// /// The API pipeline. -// /// The start environment pipeline. -// /// The logger factory. -// public void Configure( -// IApplicationBuilder app, -// IConfigureServiceApiPipeline contextPipeline, -// IStartNodePipeline startNodePipeline, -// IConfigureOpsServiceApiPipeline contextOpsServiceApiPipeline, -// IStartEnvironmentPipeline startEnvironmentPipeline, -// ILoggerFactory loggerFactory) -// { -// // Add Application Insights monitoring to the request pipeline as a very first middleware. -// app.UseApplicationInsightsRequestTelemetry(); - -// // Add Application Insights exceptions handling to the request pipeline. -// app.UseApplicationInsightsExceptionTelemetry(); - -// app.UseDiagnostics(); - -// // Add static files to the request pipeline. -// app.UseStaticFiles(); - -// // Set the error page -// if (this._hostEnv.IsDevelopment()) -// { -// app.UseDeveloperExceptionPage(); -// } -// else -// { -// app.UseStatusCodePages(); -// } - -// startNodePipeline.Run(this.NodeContext, this.NodeContext.GetPipelineContextOptions()).Wait(); - -// // Starting the environment to register Minion policies and run Minions -// var environmentName = this._configuration.GetSection("AppSettings:EnvironmentName").Value; - -// ////this.NodeContext.AddDataMessage("EnvironmentStartup", $"StartEnvironment={environmentName}"); - -// ////startEnvironmentPipeline.Run(environmentName, this.NodeContext.GetPipelineContextOptions()).Wait(); - -// // Initialize plugins OData contexts -// app.InitializeODataBuilder(); -// var modelBuilder = new ODataConventionModelBuilder(); - -// // Run the pipeline to configure the plugin's OData context -// var contextResult = contextPipeline.Run(modelBuilder, this.NodeContext.GetPipelineContextOptions()).Result; -// contextResult.Namespace = "Sitecore.Commerce.Engine"; - -// // Get the model and register the ODataRoute -// var model = contextResult.GetEdmModel(); -// app.UseRouter(new ODataRoute("Api", model)); - -// // Register the bootstrap context for the engine -// modelBuilder = new ODataConventionModelBuilder(); -// var contextOpsResult = contextOpsServiceApiPipeline.Run(modelBuilder, this.NodeContext.GetPipelineContextOptions()).Result; -// contextOpsResult.Namespace = "Sitecore.Commerce.Engine"; - -// // Get the model and register the ODataRoute -// model = contextOpsResult.GetEdmModel(); -// app.UseRouter(new ODataRoute("CommerceOps", model)); -// } - -// /// -// /// Initializes the node context. -// /// -// /// A -// private NodeContext InitializeNodeContext() -// { -// this._nodeContext = new NodeContext(this._logger, new TelemetryClient()) -// { -// CorrelationId = this._nodeInstanceId, -// ConnectionId = "Node_Global", -// ContactId = "Node_Global", -// GlobalEnvironment = this.StartupEnvironment, -// Environment = this.StartupEnvironment, -// WebRootPath = this._hostEnv.WebRootPath, -// LoggingPath = this._hostEnv.WebRootPath + @"\logs\" -// }; -// return this._nodeContext; -// } - -// /// -// /// Setups the data protection storage and encryption protection type -// /// -// /// The services. -// private void SetupDataProtection(IServiceCollection services) -// { -// var builder = services.AddDataProtection(); -// var pathToKeyStorage = this._configuration.GetSection("AppSettings:EncryptionKeyStorageLocation").Value; - -// // Persist keys to a specific directory (should be a network location in distributed application) -// builder.PersistKeysToFileSystem(new DirectoryInfo(pathToKeyStorage)); - -// var protectionType = this._configuration.GetSection("AppSettings:EncryptionProtectionType").Value.ToUpperInvariant(); - -// switch (protectionType) -// { -// case "DPAPI-SID": -// var storageSid = this._configuration.GetSection("AppSettings:EncryptionSID").Value.ToUpperInvariant(); -// //// Uses the descriptor rule "SID=S-1-5-21-..." to encrypt with domain joined user -// builder.ProtectKeysWithDpapiNG($"SID={storageSid}", flags: DpapiNGProtectionDescriptorFlags.None); -// break; -// case "DPAPI-CERT": -// var storageCertificateHash = this._configuration.GetSection("AppSettings:EncryptionCertificateHash").Value.ToUpperInvariant(); -// //// Searches the cert store for the cert with this thumbprint -// builder.ProtectKeysWithDpapiNG( -// $"CERTIFICATE=HashId:{storageCertificateHash}", -// flags: DpapiNGProtectionDescriptorFlags.None); -// break; -// case "LOCAL": -// //// Only the local user account can decrypt the keys -// builder.ProtectKeysWithDpapiNG(); -// break; -// case "MACHINE": -// //// All user accounts on the machine can decrypt the keys -// builder.ProtectKeysWithDpapi(protectToLocalMachine: true); -// break; -// default: -// //// All user accounts on the machine can decrypt the keys -// builder.ProtectKeysWithDpapi(protectToLocalMachine: true); -// break; -// } -// } - -// /// -// /// Gets the global environment. -// /// -// /// A -// private CommerceEnvironment GetGlobalEnvironment() -// { -// CommerceEnvironment environment; - -// this._logger.LogInformation($"Loading Global Environment using Filesystem Provider from: {this._hostEnv.WebRootPath} s\\Bootstrap\\"); - -// // Use the default File System provider to setup the environment -// this.NodeContext.BootStrapProviderPath = this._hostEnv.WebRootPath + @"\Bootstrap\"; -// var bootstrapProvider = new FileSystemEntityProvider(NodeContext.BootStrapProviderPath); - -// var bootstrapFile = this._configuration.GetSection("AppSettings:BootStrapFile").Value; - -// if (!string.IsNullOrEmpty(bootstrapFile)) -// { -// this.NodeContext.BootStrapEnvironmentPath = bootstrapFile; - -// this.NodeContext.AddDataMessage("NodeStartup", $"GlobalEnvironmentFrom='Configuration: {bootstrapFile}'"); -// environment = bootstrapProvider.Find(this.NodeContext, bootstrapFile, false).Result; -// } -// else -// { -// // Load the NodeContext default -// bootstrapFile = "Global"; -// this.NodeContext.BootStrapEnvironmentPath = bootstrapFile; -// this.NodeContext.AddDataMessage("NodeStartup", $"GlobalEnvironmentFrom='{bootstrapFile}.json'"); -// environment = bootstrapProvider.Find(this.NodeContext, bootstrapFile, false).Result; -// } - -// this.NodeContext.BootStrapEnvironmentPath = bootstrapFile; - -// this.NodeContext.GlobalEnvironmentName = environment.Name; -// this.NodeContext.AddDataMessage("NodeStartup", $"Status='Started',GlobalEnvironmentName='{NodeContext.GlobalEnvironmentName}'"); - -// if (this._configuration.GetSection("AppSettings:BootStrapFile").Value != null) -// { -// this.NodeContext.ContactId = this._configuration.GetSection("AppSettings:NodeId").Value; -// } - -// if (!string.IsNullOrEmpty(environment.GetPolicy().DeploymentId)) -// { -// this.NodeContext.ContactId = $"{environment.GetPolicy().DeploymentId}_{this._nodeInstanceId}"; -// } - -// return environment; -// } -// } -//} diff --git a/src/Foundation/Commerce/Engine/code/project.json b/src/Foundation/Commerce/Engine/project.json similarity index 82% rename from src/Foundation/Commerce/Engine/code/project.json rename to src/Foundation/Commerce/Engine/project.json index ac7bcad3..bd00035b 100644 --- a/src/Foundation/Commerce/Engine/code/project.json +++ b/src/Foundation/Commerce/Engine/project.json @@ -18,9 +18,13 @@ "Sitecore.Framework.Rules.Serialization": "1.1.12", "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Sitecore.Framework.Diagnostics": "1.1.4", - "Plugin.Sample.Habitat": "1.0.2301", - "Plugin.Sample.Payments.Braintree": "1.0.2301", - "Sitecore.Commerce.Plugin.AdventureWorks": "1.0.2301" + "Engine.HabitatData": "1.0.0-*", + "Sitecore.Commerce.Plugin.Catalog.Cs": "1.0.2301", + "Sitecore.Commerce.Plugin.Payments": "1.0.2301", + "Sitecore.Commerce.Plugin.Inventory.Cs": "1.0.2301", + "Sitecore.Commerce.Plugin.Tax": "1.0.2301", + "Engine.Payments": "1.0.0-*", + "Engine.Entitlements": "1.0.0-*" }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" diff --git a/src/Foundation/Commerce/Engine/code/web.config b/src/Foundation/Commerce/Engine/web.config similarity index 100% rename from src/Foundation/Commerce/Engine/code/web.config rename to src/Foundation/Commerce/Engine/web.config diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/bootstrap/Global.json b/src/Foundation/Commerce/Engine/wwwroot/bootstrap/Global.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/bootstrap/Global.json rename to src/Foundation/Commerce/Engine/wwwroot/bootstrap/Global.json diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/config.json b/src/Foundation/Commerce/Engine/wwwroot/config.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/config.json rename to src/Foundation/Commerce/Engine/wwwroot/config.json diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/CommerceOps-1.0.0.json b/src/Foundation/Commerce/Engine/wwwroot/data/Environments/CommerceOps-1.0.0.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/CommerceOps-1.0.0.json rename to src/Foundation/Commerce/Engine/wwwroot/data/Environments/CommerceOps-1.0.0.json diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/Habitat.CommerceAuthoring-1.0.0.json b/src/Foundation/Commerce/Engine/wwwroot/data/Environments/Habitat.CommerceAuthoring-1.0.0.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/Habitat.CommerceAuthoring-1.0.0.json rename to src/Foundation/Commerce/Engine/wwwroot/data/Environments/Habitat.CommerceAuthoring-1.0.0.json diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/Habitat.CommerceMinions-1.0.0.json b/src/Foundation/Commerce/Engine/wwwroot/data/Environments/Habitat.CommerceMinions-1.0.0.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/Habitat.CommerceMinions-1.0.0.json rename to src/Foundation/Commerce/Engine/wwwroot/data/Environments/Habitat.CommerceMinions-1.0.0.json diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/Habitat.CommerceShops-1.0.0.json b/src/Foundation/Commerce/Engine/wwwroot/data/Environments/Habitat.CommerceShops-1.0.0.json similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/data/Environments/Habitat.CommerceShops-1.0.0.json rename to src/Foundation/Commerce/Engine/wwwroot/data/Environments/Habitat.CommerceShops-1.0.0.json diff --git a/src/Foundation/Commerce/Engine/code/wwwroot/web.config b/src/Foundation/Commerce/Engine/wwwroot/web.config similarity index 100% rename from src/Foundation/Commerce/Engine/code/wwwroot/web.config rename to src/Foundation/Commerce/Engine/wwwroot/web.config diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/ConfigureSitecore.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/ConfigureSitecore.cs deleted file mode 100644 index bead105b..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/ConfigureSitecore.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using System.Reflection; - - using Microsoft.Extensions.DependencyInjection; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Framework.Configuration; - using Sitecore.Framework.Pipelines.Definitions.Extensions; - - /// - /// The Habitat configure class. - /// - /// - public class ConfigureSitecore : IConfigureSitecore - { - /// - /// The configure services. - /// - /// - /// The services. - /// - public void ConfigureServices(IServiceCollection services) - { - var assembly = Assembly.GetExecutingAssembly(); - services.RegisterAllPipelineBlocks(assembly); - services.RegisterAllCommands(assembly); - - services.Sitecore().Pipelines( - config => config.ConfigurePipeline( - d => - { - d.Add() - .Add() - .Add() - .Add(); - }) - - .ConfigurePipeline( - c => - { - c.Add().After() - .Add().After() - .Add().After(); - }) - - .ConfigurePipeline(c => - { - c.Add().After() - .Add().After() - .Add().After() - .Add().After() - .Add().After() - .Add().After(); - }) - - .ConfigurePipeline(d => { d.Add(); })); - } - } -} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Controller/CommandsController.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Controller/CommandsController.cs deleted file mode 100644 index 0603d96e..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Controller/CommandsController.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using System; - - using Sitecore.Commerce.Core; - - /// - /// Defines the CommandsController controller. - /// - public class CommandsController : CommerceController - { - /// - /// Initializes a new instance of the class. - /// - /// The service provider. - /// The global environment. - public CommandsController(IServiceProvider serviceProvider, CommerceEnvironment globalEnvironment) - : base(serviceProvider, globalEnvironment) - { - } - } -} - diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/DigitalProduct.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/DigitalProduct.cs deleted file mode 100644 index 76c4567e..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/DigitalProduct.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using Sitecore.Commerce.Plugin.Entitlements; - - /// - /// Defines the digital product entity. - /// - /// - public class DigitalProduct : Entitlement - { - } -} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Installation.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Installation.cs deleted file mode 100644 index 50593cd1..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Installation.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using Sitecore.Commerce.Plugin.Entitlements; - - /// - /// Defines the installation entity. - /// - /// - public class Installation : Entitlement - { - } -} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Warranty.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Warranty.cs deleted file mode 100644 index f2e0a6ad..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Entities/Warranty.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using Sitecore.Commerce.Plugin.Entitlements; - - /// - /// Defines the warranty entity. - /// - /// - public class Warranty : Entitlement - { - } -} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/HabitatConstants.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/HabitatConstants.cs deleted file mode 100644 index abbe9be1..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/HabitatConstants.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - /// - /// The Habitat constants. - /// - public static class HabitatConstants - { - /// - /// The name of the Habitat pipelines. - /// - public static class Pipelines - { - /// - /// The name of the Habitat pipeline blocks. - /// - public static class Blocks - { - /// - /// The provision warranty entitlements block name. - /// - public const string ProvisionWarrantyEntitlementsBlock = "Habitat.block.ProvisionWarrantyEntitlements"; - - /// - /// The provision installation entitlements block name. - /// - public const string ProvisionInstallationEntitlementsBlock = "Habitat.block.ProvisionInstallationEntitlements"; - - /// - /// The provision digital product entitlements block name. - /// - public const string ProvisionDigitalProductEntitlementsBlock = "Habitat.block.ProvisionDigitalProductEntitlements"; - - /// - /// The get order warranty entitlement details view block name. - /// - public const string GetOrderWarrantyEntitlementDetailsViewBlock = "Habitat.block.GetOrderWarrantyEntitlementDetailsView"; - - /// - /// The get customer warranty entitlement details view block name. - /// - public const string GetCustomerWarrantyEntitlementDetailsViewBlock = "Habitat.block.GetCustomerWarrantyEntitlementDetailsView"; - - /// - /// The get order installation entitlement details view block name. - /// - public const string GetOrderInstallationEntitlementDetailsViewBlock = "Habitat.block.GetOrderInstallationEntitlementDetailsView"; - - /// - /// The get customer installation entitlement details view block name. - /// - public const string GetCustomerInstallationEntitlementDetailsViewBlock = "Habitat.block.GetCustomerInstallationEntitlementDetailsView"; - - /// - /// The get order digital product entitlement details view block name. - /// - public const string GetOrderDigitalProductEntitlementDetailsViewBlock = "Habitat.block.GetOrderDigitalProductEntitlementDetailsView"; - - /// - /// The get customer digital product entitlement details view block name. - /// - public const string GetCustomerDigitalProductEntitlementDetailsViewBlock = "Habitat.block.GetCustomerDigitalProductEntitlementDetailsView"; - - /// - /// The bootstrap aw sellable items block name. - /// - public const string BootstrapAwSellableItemsBlock = "Habitat.block.BootstrapAwSellableItems"; - } - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Arguments/SampleArgument.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Arguments/SampleArgument.cs deleted file mode 100644 index 3c1693a5..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Arguments/SampleArgument.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using Sitecore.Commerce.Core; - using Sitecore.Framework.Conditions; - - /// - /// SampleArgument pipeline argument. - /// - public class SampleArgument : PipelineArgument - { - /// - /// Initializes a new instance of the class. - /// - /// - /// The parameter. - /// - public SampleArgument(object parameter) - { - Condition.Requires(parameter).IsNotNull("The parameter can not be null"); - - this.Parameter = parameter; - } - - /// - /// Gets or sets the parameter. - /// - public object Parameter { get; set; } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentEnsureCatalogBlock.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentEnsureCatalogBlock.cs deleted file mode 100644 index 64984937..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentEnsureCatalogBlock.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Catalog.Cs; - using Sitecore.Framework.Pipelines; - - /// - /// Ensure Habitat catalog has been loaded. - /// - [PipelineDisplayName("Habitat.InitializeEnvironmentEnsureCatalogBlock")] - public class InitializeEnvironmentHabitatEnsureCatalogBlock : PipelineBlock - { - private readonly EnsureCatalogCommand _ensureCatalogCommand; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The EnsureCatalog Command. - /// - public InitializeEnvironmentHabitatEnsureCatalogBlock(EnsureCatalogCommand ensureCatalogCommand) - { - this._ensureCatalogCommand = ensureCatalogCommand; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override async Task Run(string arg, CommercePipelineExecutionContext context) - { - await this._ensureCatalogCommand.Process(context.CommerceContext, "Habitat_Master", @"[wwwroot]\data\Catalogs\Habitat_Master.xml", "Habitat_Inventory", @"[wwwroot]\data\Catalogs\Habitat_Inventory.xml"); - - await this._ensureCatalogCommand.Process(context.CommerceContext, "Habitat_NextCubeMarketplace", @"[wwwroot]\data\Catalogs\Habitat_NextCubeMarketplace.xml", "Habitat_Inventory", @"[wwwroot]\data\Catalogs\Habitat_Inventory.xml"); - - return arg; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs deleted file mode 100644 index 4fdef089..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs +++ /dev/null @@ -1,130 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Habitat -{ - using System.Collections.Generic; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Availability; - using Sitecore.Commerce.Plugin.Catalog; - using Sitecore.Commerce.Plugin.Entitlements; - using Sitecore.Commerce.Plugin.GiftCards; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Pricing; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which initializes pricing. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName("Habitat.InitializeEnvironmentGiftCardsBlock")] - public class InitializeEnvironmentGiftCardsBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - private readonly IFindEntityPipeline _findEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. - /// - /// The find entity pipeline. - /// - public InitializeEnvironmentGiftCardsBlock( - IPersistEntityPipeline persistEntityPipeline, IFindEntityPipeline findEntityPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - this._findEntityPipeline = findEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override async Task Run(string arg, CommercePipelineExecutionContext context) - { - if (arg != "Habitat" && arg != "HabitatShops") - { - return arg; - } - - var itemId = $"{CommerceEntity.IdPrefix()}6042986"; - var findResult = await this._findEntityPipeline.Run(new FindEntityArgument(typeof(SellableItem), itemId, false), context.CommerceContext.GetPipelineContextOptions()); - - if (findResult == null) - { - var giftCard = new SellableItem - { - Id = itemId, - Name = "Default GiftCard", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List {new Money("USD", 0M), new Money("CAD", 0M)}) - }, - Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "56042986", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 25M), new Money("CAD", 26M) }) - } - }, - new ItemVariationComponent - { - Id = "56042987", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - } - }, - new ItemVariationComponent - { - Id = "56042988", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 100M), new Money("CAD", 101M) }) - } - } - } - } - } - }; - - await this._persistEntityPipeline.Run(new PersistEntityArgument(giftCard), context); - } - return arg; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/project.json b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/project.json deleted file mode 100644 index 1ac158f7..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/project.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "version": "1.0.2301", - "description": "The Sitecore Commerce Habitat Sample Plugin.", - "copyright": "© 2017 Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.", - "authors": [ - "Sitecore" - ], - "packOptions": { - "summary": "This package contains the Habitat Sample plugin for the Sitecore Commerce Engine.", - "tags": [ - "Sitecore", - "Commerce", - "Plugin", - "Sample", - "Example" - ], - "owners": [ - "Sitecore Corporation A/S" - ], - "releaseNotes": "release notes", - "iconUrl": "http://www.sitecore.net/favicon.ico", - "projectUrl": "http://www.sitecore.net/", - "licenseUrl": "http://www.sitecore.net/platform/pricing.aspx" - }, - "dependencies": { - "Sitecore.Commerce.Core": "1.0.2301", - "Sitecore.Commerce.Plugin.Catalog": "1.0.2301", - "Sitecore.Commerce.Plugin.Catalog.Cs": "1.0.2301", - "Sitecore.Commerce.Plugin.GiftCards": "1.0.2301", - "Sitecore.Commerce.Plugin.Coupons": "1.0.2301", - "Sitecore.Commerce.Plugin.Fulfillment": "1.0.2301" - }, - "frameworks": { - "net452": { - - } - }, - "configurations": { - "Release": { - "buildOptions": { - "compile": "../../shared/VersionInfo.cs", - "xmlDoc": true, - "warningsAsErrors": true, - "optimize": true - } - }, - "Demo-Retail": { - "buildOptions": { - "warningsAsErrors": true - } - }, - "Debug": { - "buildOptions": { - "warningsAsErrors": true - } - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/ConfigureSitecore.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/ConfigureSitecore.cs deleted file mode 100644 index a31863d3..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/ConfigureSitecore.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree -{ - using System.Reflection; - using Microsoft.Extensions.DependencyInjection; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Configuration; - using Sitecore.Framework.Pipelines.Definitions.Extensions; - - /// - /// The pricing configure sitecore class - /// - /// - public class ConfigureSitecore : IConfigureSitecore - { - /// - /// The configure services. - /// - /// - /// The services. - /// - public void ConfigureServices(IServiceCollection services) - { - var assembly = Assembly.GetExecutingAssembly(); - services.RegisterAllPipelineBlocks(assembly); - - services.Sitecore().Pipelines(config => config - - .ConfigurePipeline(d => - { - d.Add().After(); - }) - .ConfigurePipeline(d => - { - d.Add().Before(); - }) - .ConfigurePipeline(d => - { - d.Add().After(); - }) - .ConfigurePipeline(d => - { - d.Add().After() - .Add().After() - .Add().Before(); - }) - .ConfigurePipeline(d => - { - d.Add().After(); - }) - .ConfigurePipeline(d => - { - d.Add().After(); - }) - - ); - - services.RegisterAllCommands(assembly); - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Helpers/ComponentsHelper.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Helpers/ComponentsHelper.cs deleted file mode 100644 index a0fff37c..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Helpers/ComponentsHelper.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree -{ - using global::Braintree; - using Sitecore.Commerce.Core; - - /// - /// A Components Helper to translate party for address request - /// - public class ComponentsHelper - { - /// - /// Translates the party to address request. - /// - /// The party. - /// The context. - /// - internal static protected AddressRequest TranslatePartyToAddressRequest(Party party, CommercePipelineExecutionContext context) - { - var addressRequest = new AddressRequest(); - addressRequest.CountryCodeAlpha2 = party.CountryCode; - addressRequest.CountryName = party.Country; - addressRequest.FirstName = party.FirstName; - addressRequest.LastName = party.LastName; - addressRequest.PostalCode = party.ZipPostalCode; - addressRequest.StreetAddress = string.Concat(party.Address1, ",", party.Address2); - - return addressRequest; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/PaymentsBraintreeConstants.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/PaymentsBraintreeConstants.cs deleted file mode 100644 index 06475507..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/PaymentsBraintreeConstants.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree -{ - /// - /// The payments constants. - /// - public static class PaymentsBraintreeConstants - { - /// - /// The name of the payments pipelines. - /// - public static class Pipelines - { - /// - /// The name of the payment pipelines blocks. - /// - public static class Blocks - { - /// - /// The get client token block name. - /// - public const string GetClientTokenBlock = "PaymentsBraintree.block.getclienttoken"; - - /// - /// The add federated payment block - /// - public const string UpdateFederatedPaymentBlock = "PaymentsBraintree.block.updatefederatedpayment"; - - /// - /// The update federated payment after settlement block - /// - public const string UpdateFederatedPaymentAfterSettlementBlock = "PaymentsBraintree.block.updatefederatedpaymentaftersettlement"; - - /// - /// The create federated payment block - /// - public const string CreateFederatedPaymentBlock = "PaymentsBraintree.block.createfederatedpayment"; - - /// - /// The ensure settle payment requested block - /// - public const string EnsureSettlePaymentRequestedBlock = "PaymentsBraintree.block.ensuresettlepaymentrequested"; - - /// - /// The void federated payment block - /// - public const string VoidFederatedPaymentBlock = "PaymentsBraintree.block.voidfederatedpayment"; - - /// - /// The void cancel order federated payment block - /// - public const string VoidCancelOrderFederatedPaymentBlock = "PaymentsBraintree.block.voidcancelorderfederatedpayment"; - - /// - /// The refund federated payment block - /// - public const string RefundFederatedPaymentBlock = "PaymentsBraintree.block.refundfederatedpayment"; - - /// - /// The void on hold order federated payment block - /// - public const string VoidOnHoldOrderFederatedPaymentBlock = "PaymentsBraintree.block.voidonholdorderfederatedpayment"; - - /// - /// The validate settlement block - /// - public const string ValidateSettlementBlock = "PaymentsBraintree.block.validatesettlement"; - } - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs deleted file mode 100644 index a5e33e37..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Pipelines/Blocks/UpdateFederatedPaymentAfterSettlementBlock.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree -{ - using System.Threading.Tasks; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Framework.Conditions; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which updates transaction Id for an order. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{Sitecore.Commerce.Plugin.Orders.SalesActivity, - /// Sitecore.Commerce.Plugin.Orders.SalesActivity, Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(PaymentsBraintreeConstants.Pipelines.Blocks.UpdateFederatedPaymentAfterSettlementBlock)] - public class UpdateFederatedPaymentAfterSettlementBlock : PipelineBlock - { - private readonly GetOrderCommand _getOrderCommand; - private readonly IPersistEntityPipeline _persistEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// The get order command. - /// The persist entity pipeline. - public UpdateFederatedPaymentAfterSettlementBlock(GetOrderCommand getOrderCommand, IPersistEntityPipeline persistEntityPipeline) - { - this._getOrderCommand = getOrderCommand; - this._persistEntityPipeline = persistEntityPipeline; - } - - /// - /// Runs the specified argument. - /// - /// The argument. - /// The context. - /// - /// A cart with federate payment component - /// - public async override Task Run(SalesActivity arg, CommercePipelineExecutionContext context) - { - Condition.Requires(arg).IsNotNull($"{this.Name}: sales activity can not be null."); - if (!arg.HasComponent()) - { - return arg; - } - - var order = await this._getOrderCommand.Process(context.CommerceContext, arg.Order.EntityTarget); - - if (order == null || !order.HasComponent()) - { - return arg; - } - - var orderPayment = order.GetComponent(); - - var payment = arg.GetComponent(); - orderPayment.TransactionStatus = payment.TransactionStatus; - - await this._persistEntityPipeline.Run(new PersistEntityArgument(order), context); - return arg; - } - } -} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Plugin.Sample.Payments.Braintree.xproj b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Plugin.Sample.Payments.Braintree.xproj deleted file mode 100644 index 1382031d..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Plugin.Sample.Payments.Braintree.xproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 0296f347-f76d-4a81-9fb1-ae9ca0f0c064 - Plugin.Sample.Payments.Braintree - ..\artifacts\obj\$(MSBuildProjectName) - .\bin\ - SAK - SAK - SAK - SAK - - - 2.0 - - - False - - - True - - - \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Policies/BraintreeClientPolicy.cs b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Policies/BraintreeClientPolicy.cs deleted file mode 100644 index 0224a254..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/Policies/BraintreeClientPolicy.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Plugin.Sample.Payments.Braintree -{ - using Sitecore.Commerce.Core; - - /// - /// Defines the BraintreeClientPolicy for Payments. - /// - public class BraintreeClientPolicy : Policy - { - /// - /// Initializes a new instance of the class. - /// - public BraintreeClientPolicy() - { - this.Environment = string.Empty; - this.MerchantId = string.Empty; - this.PublicKey = string.Empty; - this.PrivateKey = string.Empty; - } - - /// - /// Gets or sets the environment. - /// - /// - /// The environment. - /// - public string Environment { get; set; } - - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public string MerchantId { get; set; } - - /// - /// Gets or sets the public key. - /// - /// - /// The public key. - /// - public string PublicKey { get; set; } - - /// - /// Gets or sets the private key. - /// - /// - /// The private key. - /// - public string PrivateKey { get; set; } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/project.json b/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/project.json deleted file mode 100644 index 50b3e552..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Payments.Braintree/project.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "version": "1.0.2301", - "description": "A Sample Payments Plugin using Braintree.", - "copyright": "© 2017 Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.", - "authors": [ - "Sitecore" - ], - "packOptions": { - "summary": "This package contains the Payments plugin for the Sitecore Commerce Engine.", - "tags": [ - "Sitecore", - "Commerce", - "Plugin", - "Sample", - "Example" - ], - "owners": [ - "Sitecore Corporation A/S" - ], - "releaseNotes": "release notes", - "iconUrl": "http://www.sitecore.net/favicon.ico", - "projectUrl": "http://www.sitecore.net/", - "licenseUrl": "http://www.sitecore.net/platform/pricing.aspx" - }, - "dependencies": { - "Braintree": "3.3.0", - "Sitecore.Commerce.Plugin.Payments": "1.0.2301" - }, - "frameworks": { - "net452": { - - } - }, - "configurations": { - "Release": { - "buildOptions": { - "compile": "../../build/VersionInfo.cs", - "xmlDoc": true, - "warningsAsErrors": true, - "optimize": true - } - }, - "Demo-Retail": { - "buildOptions": { - "warningsAsErrors": true - } - }, - "Debug": { - "buildOptions": { - "warningsAsErrors": true - } - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/AwConstants.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/AwConstants.cs deleted file mode 100644 index bab0403d..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/AwConstants.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -// The adventure works constants. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - /// - /// The adventure works constants. - /// - public static class AwConstants - { - /// - /// The names of the adventure works pipelines. - /// - public static class Pipelines - { - /// - /// The names of the adventure works pipelines blocks. - /// - public static class Blocks - { - /// - /// The bootstrap aw minions block name. - /// - public const string BootstrapAwMinionsBlock = "AdventureWorks:block:bootstrapawminions"; - - /// - /// The InitializeEnvironmentGiftCardsBlock name. - /// - public const string InitializeEnvironmentGiftCardsBlock = "AdventureWorks.InitializeEnvironmentGiftCardsBlock"; - - /// - /// The InitializeEnvironmentEnsureCatalogBlock name. - /// - public const string InitializeEnvironmentEnsureCatalogBlock = "AdventureWorks:block:initializeenvironmentensurecatalogblock"; - - /// - /// The bootstrap aw pricing block name. - /// - public const string InitializeEnvironmentPricingBlock = "AdventureWorks.InitializeEnvironmentPricingBlock"; - - /// - /// The bootstrap aw sellable items block name. - /// - public const string BootstrapAwSellableItemsBlock = "AdventureWorks:block:bootstrapawsellableitems"; - - /// - /// The bootstrap aw promotions block name. - /// - public const string InitializeEnvironmentPromotionsBlock = "AdventureWorks.InitializeEnvironmentPromotionsBlock"; - - /// - /// The bootstrap aw shops block name. - /// - public const string InitializeEnvironmentShopsBlock = "AdventureWorks.InitializeEnvironmentShopsBlock"; - - /// - /// The bootstrap aw regions block name. - /// - public const string InitializeEnvironmentRegionsBlock = "AdventureWorks.InitializeEnvironmentRegionsBlock"; - - /// - /// The bootstrap adventure works block name. - /// - public const string BootstrapAdventureWorksBlock = "AdventureWorks:block:bootstrapaw"; - - /// - /// The bootstrap aw policy sets block name. - /// - public const string InitializeEnvironmentPolicySetsBlock = "AdventureWorks.InitializeEnvironmentPolicySetsBlock"; - - /// - /// The registered plugin block name. - /// - public const string RegisteredPluginBlock = "AdventureWorks:block:registeredplugin"; - - /// - /// The Bootstrap ManagedLists Block Name. - /// - public const string BootstrapManagedListsBlock = "Orders.block.BootstrapManagedListsBlock"; - } - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ConfigureSitecore.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ConfigureSitecore.cs deleted file mode 100644 index dd0b2129..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ConfigureSitecore.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Reflection; - - using Microsoft.Extensions.DependencyInjection; - using Sitecore.Commerce.Core; - using Sitecore.Framework.Configuration; - using Sitecore.Framework.Pipelines.Definitions.Extensions; - - /// - /// Defines the configure sitecore class for the AdventureWorks plugin. - /// - /// - public class ConfigureSitecore : IConfigureSitecore - { - /// - /// The configure services. - /// - /// - /// The services. - /// - public void ConfigureServices(IServiceCollection services) - { - var assembly = Assembly.GetExecutingAssembly(); - services.RegisterAllPipelineBlocks(assembly); - - services.Sitecore().Pipelines(config => config - .ConfigurePipeline(d => d.Add()) - - .ConfigurePipeline(d => - { - d.Add() - .Add() - .Add() - .Add() - .Add() - .Add() - .Add(); - }) - - .ConfigurePipeline(d => { }) - - .ConfigurePipeline(c => { c.Add().After(); })); - - services.ConfigureCartPipelines(); - services.ConfigureOrdersPipelines(); - } - } -} \ No newline at end of file diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapAwEnvironmentBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapAwEnvironmentBlock.cs deleted file mode 100644 index c30f3800..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapAwEnvironmentBlock.cs +++ /dev/null @@ -1,537 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - using global::Plugin.Sample.Payments.Braintree; - using Microsoft.Extensions.Logging; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Core.Caching; - using Sitecore.Commerce.EntityViews; - using Sitecore.Commerce.Plugin.Backorderable; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.CsAgent; - using Sitecore.Commerce.Plugin.Customers.Cs; - using Sitecore.Commerce.Plugin.Fulfillment; - using Sitecore.Commerce.Plugin.Inventory; - using Sitecore.Commerce.Plugin.Inventory.Cs; - using Sitecore.Commerce.Plugin.Journaling; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Management; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Preorderable; - using Sitecore.Commerce.Plugin.Pricing; - using Sitecore.Commerce.Plugin.Promotions; - using Sitecore.Commerce.Plugin.Returns; - using Sitecore.Commerce.Plugin.SQL; - using Sitecore.Commerce.Plugin.Tax; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps the AdventureWorks environment. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.BootstrapAdventureWorksBlock)] - public class BootstrapAwEnvironmentBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - private readonly IFindEntityPipeline _findEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The find entity pipeline. - /// - /// - /// The findEntityPipeline. - /// - public BootstrapAwEnvironmentBlock(IPersistEntityPipeline persistEntityPipeline, IFindEntityPipeline findEntityPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - this._findEntityPipeline = findEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override Task Run(string arg, CommercePipelineExecutionContext context) - { - context.Logger.LogInformation($"{this.Name} - Run"); - - // Set up initial AdventureWorks environment as an in-memory store - //var environment = new CommerceEnvironment - //{ - // Id = $"{CommerceEntity.IdPrefix()}AdventureWorks", - // EnvironmentId = new Guid("{0F832C48-694E-4492-94B3-1F196E277299}"), - // Name = "AdventureWorks", - // Components = - // new List - // { - // new ListMembershipsComponent - // { - // Memberships = - // new List { CommerceEntity.ListName() } - // } - // }, - // Policies = - // new List - // { - // new EnvironmentInitializationPolicy - // { - // InitialArtifactSets = new List - // { - // "Carts.CartsGlobalPolicySets-1.0.*", - // "GiftCards.TestGiftCards-1.0.*", - // "Environment.AdventureWorks.PolicySets-1.0.*", - // "Environment.Pricing-1.0.*", - // "Environment.Promotions-1.0.*", - // "Environment.Regions-1.0.*", - // "Environment.SellableItems-1.0.*", - // "Environment.Shops-1.0.*", - // "Pricing.DefaultPriceBook-1.0.*" - // } - // }, - // new ActionsRolesPolicy(new List - // { - // //// SNAPSHOTS - // new ActionRoleModel(context.GetPolicy().PriceSnapshotDetails, context.GetPolicy().RequestSnapshotApproval, "sitecore\\Pricer"), - // new ActionRoleModel(context.GetPolicy().PriceSnapshotDetails, context.GetPolicy().RequestSnapshotApproval, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().PriceSnapshotDetails, context.GetPolicy().RejectSnapshot, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().PriceSnapshotDetails, context.GetPolicy().ApproveSnapshot, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().PriceSnapshotDetails, context.GetPolicy().RetractSnapshot, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().SetSnapshotApprovalStatus, context.GetPolicy().RequestSnapshotApproval, "sitecore\\Pricer"), - // new ActionRoleModel(context.GetPolicy().SetSnapshotApprovalStatus, context.GetPolicy().RequestSnapshotApproval, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().SetSnapshotApprovalStatus, context.GetPolicy().RejectSnapshot, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().SetSnapshotApprovalStatus, context.GetPolicy().ApproveSnapshot, "sitecore\\Pricer Manager"), - // new ActionRoleModel(context.GetPolicy().SetSnapshotApprovalStatus, context.GetPolicy().RetractSnapshot, "sitecore\\Pricer Manager"), - - // //// PROMOTIONS - // new ActionRoleModel(context.GetPolicy().Details, context.GetPolicy().RequestPromotionApproval, "sitecore\\Promotioner"), - // new ActionRoleModel(context.GetPolicy().Details, context.GetPolicy().RequestPromotionApproval, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().Details, context.GetPolicy().RejectPromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().Details, context.GetPolicy().ApprovePromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().Details, context.GetPolicy().RetractPromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().Details, context.GetPolicy().DisablePromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().SetPromotionApprovalStatus, context.GetPolicy().RequestPromotionApproval, "sitecore\\Promotioner"), - // new ActionRoleModel(context.GetPolicy().SetPromotionApprovalStatus, context.GetPolicy().RequestPromotionApproval, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().SetPromotionApprovalStatus, context.GetPolicy().RejectPromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().SetPromotionApprovalStatus, context.GetPolicy().ApprovePromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().SetPromotionApprovalStatus, context.GetPolicy().RetractPromotion, "sitecore\\Promotioner Manager"), - // new ActionRoleModel(context.GetPolicy().SetPromotionApprovalStatus, context.GetPolicy().DisablePromotion, "sitecore\\Promotioner Manager") - // }), - // new GlobalEnvironmentPolicy - // { - // Languages = new List { "en-US", "en-CA", "es", "fr-CA" }, - // DefaultCurrency = "USD", - // DefaultCountry = - // new EntityReference - // { - // EntityTarget = $"{CommerceEntity.IdPrefix()}USA" - // }, - // Countries = - // new List - // { - // new EntityReference - // { - // EntityTarget = $"{CommerceEntity.IdPrefix()}USA" - // }, - // new EntityReference - // { - // EntityTarget = $"{CommerceEntity.IdPrefix()}CAN" - // } - // }, - // DefaultLocale = "en-US", - // TimeZone = "PST", - // FirstDayOfWeek = "Sunday" - // }, - // new EntityStoreSqlPolicy - // { - // Server = ".", - // Database = "SitecoreCommerce_SharedEnvironments", - // TrustedConnection = true, - // UserName = string.Empty, - // Password = string.Empty - // }, - // new InventoryCatalogSqlPolicy - // { - // Server = ".", - // Database = "CFSolutionStorefrontSite_productcatalog", - // TrustedConnection = true, - // UserName = string.Empty, - // Password = string.Empty - // }, - // new CsCatalogPolicy - // { - // SiteName = "CFSolutionStorefrontSite", - // DebugLevel = "Production", - // ServiceUrl = - // @"http://localhost:1004/CFSolutionStorefrontSite_CatalogWebService/CatalogWebService.asmx", - // CacheEnable = true, - // SchemaTimeout = "10", - // ItemInformationCacheTimeout = "10", - // ItemHierarchyCacheTimeout = "10", - // ItemRelationshipsCacheTimeout = "10", - // ItemAssociationsCacheTimeout = "10", - // CatalogCollectionCacheTimeout = "10", - // EnableInventorySystem = true - // }, - // new CsProfilesPolicy - // { - // SiteName = "CFSolutionStorefrontSite", - // DebugLevel = "Production", - // PublicKey = - // @"registry:HKEY_LOCAL_MACHINE\SOFTWARE\CommerceServer\Encryption\Keys\CSSolutionStorefrontSite,PublicKey", - // PrivateKey1 = - // @"registry:HKEY_LOCAL_MACHINE\SOFTWARE\CommerceServer\Encryption\Keys\CSSolutionStorefrontSite,PrivateKey", - // KeyIndex = "1" - // }, - // new ProfilesSqlPolicy - // { - // Server = ".", - // Database = "CFSolutionStorefrontSite_profiles", - // TrustedConnection = true, - // UserName = string.Empty, - // Password = string.Empty - // }, - // new SitecoreConnectionPolicy - // { - // SitecoreDatabase = "master", - // UserName = "admin", - // Password = "b", - // Domain = "sitecore", - // Host = "cf.reference.storefront.com" - // }, - // new SitecoreControlPanelItemsPolicy - // { - // StorefrontsPath = - // "/sitecore/Commerce/Commerce Control Panel/Storefronts", - // CurrencySetsPath = - // "/sitecore/Commerce/Commerce Control Panel/Currency Sets", - // LanguageSetsPath = - // "/sitecore/Commerce/Commerce Control Panel/Language Sets", - // CommerceTermsLocalizableMessagesPath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/System Messages", - // CommerceTermsFulfillmentOptionsPath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/Fulfillment Options", - // CommerceTermsFulfillmentMethodsPath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/Fulfillment Methods", - // CommerceTermsPaymentOptionsPath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/Payment Options", - // CommerceTermsPaymentMethodsPath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/Payment Methods", - // PaymentMethodItemTemplateName = "Federated" - // }, - // new SitecoreUserTermsPolicy - // { - // AccountStatusPath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/CS User Site Terms/Account Status", - // UserTypePath = - // "/sitecore/Commerce/Commerce Control Panel/Commerce Terms/CS User Site Terms/User Type", - // AllLanguagesPath = - // "/sitecore/Commerce/Commerce Control Panel/Language Sets/All Languages" - // }, - // new BraintreeClientPolicy - // { - // Environment = "sandbox", - // MerchantId = "ck4y8hkx8wzkrnnw", - // PublicKey = "wnjjxs5cc98tvzdm", - // PrivateKey = "ef47369f92cd023013e584a98314b29b" - // }, - // new RollupCartLinesPolicy { Rollup = true }, - // //// Global caching policy for all entities - // //// Can be overridden by a specific policy for a specific entity - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "*", - // AllowCaching = true, - // Priority = "Normal", - // Expiration = 60000 - // }, - // //// Dont cache orders - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Orders.Order", - // AllowCaching = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Orders.SalesActivity", - // AllowCaching = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Journaling.JournalEntry", - // AllowCaching = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Fulfillment.Shipment", - // AllowCaching = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Carts.Cart", - // AllowCaching = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.GiftCards.GiftCard", - // AllowCaching = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.ManagedLists.ManagedList", - // AllowCaching = true, - // HasNegativeCaching = true, - // CacheAsEntity = true - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Core.EntityIndex", - // AllowCaching = true, - // CacheAsEntity = true - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Promotions.Promotion", - // AllowCaching = true, - // CacheAsEntity = true - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Coupons.Coupon", - // AllowCaching = true, - // CacheAsEntity = true - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Catalog.SellableItem", - // AllowCaching = true, - // CacheAsEntity = true - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Pricing.PriceCard", - // AllowCaching = true, - // CacheAsEntity = false - // }, - // new EntityMemoryCachingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Core.NegativeCache", - // AllowCaching = true, - // CacheAsEntity = true - // }, - // new EntityJournalingPolicy - // { - // EntityFullName = "Sitecore.Commerce.Plugin.Orders.Order", - // Journal = "OrdersJournal" - // }, - // new RequestRmaReasonsPolicy - // { - // List = - // new List - // { - // new RmaReason - // { - // Code = "WrongItem", - // Description = "The wrong item was sent" - // }, - // new RmaReason - // { - // Code = "DidNotLike", - // Description = "Customer did not like item" - // } - // }, - // AllowReturnStatuses = new List { "Completed", "Released" } - // }, - // new MinionPolicy( - // "Sitecore.Commerce.Core.NodeHeartBeatMinion, Sitecore.Commerce.Core", - // string.Empty, - // TimeSpan.FromSeconds(1)), - // new MinionBossPolicy( - // "Sitecore.Commerce.Plugin.Orders.PendingOrdersMinionBoss, Sitecore.Commerce.Plugin.Orders", - // context.GetPolicy().PendingOrders, - // TimeSpan.FromMinutes(1)) - // { - // Children = new List - // { - // new MinionPolicy( - // "Sitecore.Commerce.Plugin.Orders.PendingOrdersMinion, Sitecore.Commerce.Plugin.Orders", - // $"{context.GetPolicy().PendingOrders}.1", - // TimeSpan.FromMinutes(5)), - // new MinionPolicy( - // "Sitecore.Commerce.Plugin.Orders.PendingOrdersMinion, Sitecore.Commerce.Plugin.Orders", - // $"{context.GetPolicy().PendingOrders}.2", - // TimeSpan.FromMinutes(5)) - // } - // }, - // new MinionPolicy( - // "Sitecore.Commerce.Plugin.Orders.ReleasedOrdersMinion, Sitecore.Commerce.Plugin.Orders", - // context.GetPolicy().ReleasedOrders, - // TimeSpan.FromMinutes(5)), - // new MinionPolicy( - // "Sitecore.Commerce.Plugin.Backorderable.BackOrdersMinion, Sitecore.Commerce.Plugin.Backorderable", - // context.GetPolicy().BackOrders, - // TimeSpan.FromMinutes(5)), - // new MinionPolicy( - // "Sitecore.Commerce.Plugin.Preorderable.PreOrdersMinion, Sitecore.Commerce.Plugin.Preorderable", - // context.GetPolicy().PreOrders , - // TimeSpan.FromMinutes(5)), - // new ListNamePolicy { Prefix = "List", Separator = "-", Suffix = "ByDate" }, - // new GlobalOrderPolicy - // { - // PolicyId = typeof(GlobalOrderPolicy).Name, - // InvoicePrefix = "aaa", - // InvoiceSuffix = "zzz", - // AllowOrderCancel = true, - // SubmittedOrderList = "PendingOrders", - // CompletedOrderList = "CompletedOrders" - // }, - // new OnHoldOrdersPolicy - // { - // AllowHoldStatuses = new List { "Pending", "Problem" } - // }, - // new CancelOrdersPolicy - // { - // AllowCancelStatuses = - // new List { "Pending", "Problem", "OnHold" } - // }, - // new GlobalInventoryPolicy - // { - // PolicyId = typeof(GlobalInventoryPolicy).Name, - // CheckStockLevel = true, - // SubtractStockOnOrder = true, - // DefaultAllocationDateAvailable = DateTimeOffset.MinValue - // }, - // new GlobalPhysicalFulfillmentPolicy - // { - // PolicyId = typeof(GlobalPhysicalFulfillmentPolicy).Name, - // MaxShippingWeight = 50, - // MeasurementUnits = "Inches", - // WeightUnits = "Lbs", - // DefaultCartFulfillmentFee = new Money("USD", 3M), - // DefaultCartFulfillmentFees = - // new List() { new Money("USD", 10M), new Money("CAD", 12M) }, - // DefaultItemFulfillmentFee = new Money("USD", 3M), - // DefaultItemFulfillmentFees = - // new List() { new Money("USD", 2M), new Money("CAD", 3M) }, - // FulfillmentFees = - // new List - // { - // new FulfillmentFee - // { - // Name = "Ground", - // Fee = new Money("USD", 15) - // }, - // new FulfillmentFee - // { - // Name = "Standard", - // Fee = new Money("USD", 2) - // }, - // new FulfillmentFee - // { - // Name = "Next Day Air", - // Fee = new Money("USD", 5) - // }, - // new FulfillmentFee - // { - // Name = "Standard Overnight", - // Fee = new Money("USD", 10) - // }, - // new FulfillmentFee - // { - // Name = "Ground", - // Fee = new Money("CAD", 15) - // }, - // new FulfillmentFee - // { - // Name = "Standard", - // Fee = new Money("CAD", 2) - // }, - // new FulfillmentFee - // { - // Name = "Next Day Air", - // Fee = new Money("CAD", 5) - // }, - // new FulfillmentFee - // { - // Name = "Standard Overnight", - // Fee = new Money("CAD", 10) - // } - // } - // }, - // new GlobalCheckoutPolicy - // { - // PolicyId = typeof(GlobalCheckoutPolicy).Name, - // EnableGuestCheckout = true, - // EnableQuickCheckout = true, - // EnableTermsAndConditions = true, - // MinimumOrderQuantity = 1 - // }, - // new GlobalTaxPolicy { DefaultCartTaxRate = .1M, DefaultItemTaxRate = .1M }, - // new GeoLocationDefaultsPolicy - // { - // AreaCode = "613", - // IpAddress = "127.0.0.1" - // }, - // } - //}; - - //var existingEnvironment = this._findEntityPipeline.Run(new FindEntityArgument(typeof(CommerceEnvironment), environment.Id), context).Result as CommerceEnvironment; - //if (existingEnvironment != null) - //{ - // environment.IsPersisted = true; - //} - - //try - //{ - // this._persistEntityPipeline.Run(new PersistEntityArgument(environment), context).Wait(); - //} - //catch (System.Exception ex) - //{ - // context.Logger.LogError($"Exception in BootstrapAwEnvironmentBlock - {ex}"); - // throw; - //} - - // Set up Azure variant of AdventureWorks Environment - //var environmentAzure = environment.Clone(); - //environmentAzure.Id = $"{CommerceEntity.IdPrefix()}AdventureWorksSQLAzure"; - //((CommerceEnvironment)environmentAzure).EnvironmentId = new Guid("{F0C171B7-6F2B-46FE-B2F0-979ED9B00897}"); - //environmentAzure.Name = "AdventureWorksSQLAzure"; - //environmentAzure.Policies.Remove(environmentAzure.GetPolicy()); - //environmentAzure.Policies.Add(new EntityStoreSqlPolicy { Server = "sc821dev01.database.windows.net", TrustedConnection = false, UserName = "ctpuser", Password = "Sitec0re123!" }); - - //existingEnvironment = this._findEntityPipeline.Run(new FindEntityArgument(typeof(CommerceEnvironment), environmentAzure.Id), context).Result as CommerceEnvironment; - //if (existingEnvironment != null) - //{ - // environmentAzure.IsPersisted = true; - //} - - //this._persistEntityPipeline.Run(new PersistEntityArgument(environmentAzure), context).Wait(); - - return Task.FromResult(arg); - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapManagedListsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapManagedListsBlock.cs deleted file mode 100644 index 11703b89..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/BootstrapManagedListsBlock.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Threading.Tasks; - - using ManagedLists; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps any ManagedLists for this Plugin. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.BootstrapManagedListsBlock)] - public class BootstrapManagedListsBlock : PipelineBlock - { - private readonly CreateManagedListCommand _createManagedListCommand; - private readonly GetManagedListCommand _getManagedListCommand; - - /// - /// Initializes a new instance of the class. - /// - /// The create managed list. - /// The get managed list command. - public BootstrapManagedListsBlock( - CreateManagedListCommand createManagedList, - GetManagedListCommand getManagedListCommand) - { - this._createManagedListCommand = createManagedList; - this._getManagedListCommand = getManagedListCommand; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override async Task Run(string arg, CommercePipelineExecutionContext context) - { - var pendingOrdersListName = context.GetPolicy().PendingOrders; - var managedList = await this._getManagedListCommand.Process(context.CommerceContext, pendingOrdersListName); - if (managedList != null) - { - return arg; - } - - await this._createManagedListCommand.Process(context.CommerceContext, pendingOrdersListName); - return arg; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPolicySetsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPolicySetsBlock.cs deleted file mode 100644 index d9ee4194..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPolicySetsBlock.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Collections.Generic; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Coupons; - using Sitecore.Framework.Pipelines; - using Microsoft.Extensions.Logging; - - /// - /// Defines a block which bootstraps policy sets for the AdventureWorks sample environment. - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.InitializeEnvironmentPolicySetsBlock)] - public class InitializeEnvironmentPolicySetsBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The find entity pipeline. - /// - public InitializeEnvironmentPolicySetsBlock(IPersistEntityPipeline persistEntityPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override Task Run(string arg, CommercePipelineExecutionContext context) - { - var artifactSet = "Environment.AdventureWorks.PolicySets-1.0"; - - //Check if this environment has subscribed to this Artifact Set - if (!context.GetPolicy().InitialArtifactSets.Contains(artifactSet)) - { - return Task.FromResult(arg); - } - - context.Logger.LogInformation($"{this.Name}.InitializingArtifactSet: ArtifactSet={artifactSet}"); - - //var globalCartPolicies = new PolicySet - //{ - // Id = $"{CommerceEntity.IdPrefix()}GlobalCartPolicies", - // Name = "GlobalCartPolicies", - // Policies = new List - // { - // new GlobalCartPolicy - // { - // PolicyId = typeof(GlobalCartPolicy).Name, - // MaximumLineItems = 10, - // MaximumCartValue = new MultiCurrency - // { - // Values = new List - // { - // new Money { CurrencyCode = "USD", Amount = 1000M }, - // new Money { CurrencyCode = "CAD", Amount = 500M } - // } - // }, - // ShowCartAfterAdd = true - // }, - // new CartCouponsPolicy - // { - // PolicyId = typeof(CartCouponsPolicy).Name, - // MaxCouponsInCart = 2 - // } - // } - //}; - //await this._persistEntityPipeline.Run(new PersistEntityArgument(globalCartPolicies), context); - - //var globalSellableItemPolicies = new PolicySet - //{ - // Id = $"{CommerceEntity.IdPrefix()}GlobalSellableItemPolicies", - // Name = "GlobalSellableItemPolicies", - // Policies = new List() - //}; - //await this._persistEntityPipeline.Run(new PersistEntityArgument(globalSellableItemPolicies), context); - - return Task.FromResult(arg); - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs deleted file mode 100644 index c0e5080a..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs +++ /dev/null @@ -1,296 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -using Microsoft.Extensions.Logging; - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Pricing; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps pricing the AdventureWorks sample environment. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.InitializeEnvironmentPricingBlock)] - public class InitializeEnvironmentPricingBlock : PipelineBlock - { - private readonly IAddPriceBookPipeline _addPriceBookPipeline; - private readonly IAddPriceCardPipeline _addPriceCardPipeline; - private readonly IAddPriceSnapshotPipeline _addPriceSnapshotPipeline; - private readonly IAddPriceTierPipeline _addPriceTierPipeline; - private readonly IAddPriceSnapshotTagPipeline _addPriceSnapshotTagPipeline; - private readonly IPersistEntityPipeline _persistEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// The add price book pipeline. - /// The add price card pipeline. - /// The add price snapshot pipeline. - /// The add price tier pipeline. - /// The add price snapshot tag pipeline. - /// The persist entity pipeline. - public InitializeEnvironmentPricingBlock( - IAddPriceBookPipeline addPriceBookPipeline, - IAddPriceCardPipeline addPriceCardPipeline, - IAddPriceSnapshotPipeline addPriceSnapshotPipeline, - IAddPriceTierPipeline addPriceTierPipeline, - IAddPriceSnapshotTagPipeline addPriceSnapshotTagPipeline, - IPersistEntityPipeline persistEntityPipeline) - { - this._addPriceBookPipeline = addPriceBookPipeline; - this._addPriceCardPipeline = addPriceCardPipeline; - this._addPriceSnapshotPipeline = addPriceSnapshotPipeline; - this._addPriceTierPipeline = addPriceTierPipeline; - this._addPriceSnapshotTagPipeline = addPriceSnapshotTagPipeline; - this._persistEntityPipeline = persistEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override async Task Run(string arg, CommercePipelineExecutionContext context) - { - var artifactSet = "Environment.AdventureWorks.Pricing-1.0"; - - // Check if this environment has subscribed to this Artifact Set - if (!context.GetPolicy().InitialArtifactSets.Contains(artifactSet)) - { - return arg; - } - - context.Logger.LogInformation($"{this.Name}.InitializingArtifactSet: ArtifactSet={artifactSet}"); - - try - { - // ADVENTURE WORKS BOOK - var adventureBook = await this._addPriceBookPipeline.Run( - new AddPriceBookArgument("AdventureWorksPriceBook") - { - ParentBook = "DefaultPriceBook", - Description = "Adventure works price book", - DisplayName = "Adventure Works", - CurrencySetId = "{4B494292-598E-4A61-A156-D7501F7953ED}" - }, - context); - - this.CreateProductsCard(adventureBook, context); - - this.CreateVariantsCard(adventureBook, context); - - this.CreateTagsCard(adventureBook, context); - } - catch (Exception ex) - { - context.Logger.LogError(new EventId(), ex, $"{this.Name}.Exception: Message={ex.Message}"); - } - - return arg; - } - - /// - /// Creates the products card. - /// - /// The book. - /// The context. - private void CreateProductsCard(PriceBook book, CommercePipelineExecutionContext context) - { - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - var date = DateTimeOffset.UtcNow; - - // ADVENTURE CARD - var adventureCard = this._addPriceCardPipeline.Run(new AddPriceCardArgument(book, "AdventureWorksPriceCard"), context).Result; - - // READY FOR APPROVAL SNAPSHOT - adventureCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureCard, new PriceSnapshotComponent(date.AddMinutes(-10))), context).Result; - var readyForApprovalSnapshot = adventureCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, readyForApprovalSnapshot, new PriceTier("USD", 1, 2000M)), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - // ADVENTURE CARD FIRST SNAPSHOT - adventureCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureCard, new PriceSnapshotComponent(date.AddHours(-1))), context).Result; - var firstSnapshot = adventureCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("USD", 1, 10M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("USD", 5, 5M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("USD", 10, 1M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("CAD", 1, 15M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("CAD", 5, 10M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("CAD", 10, 5M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, firstSnapshot, new PriceTier("EUR", 1, 1M)), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - // DRAFT SNAPSHOT - adventureCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureCard, new PriceSnapshotComponent(date)), context).Result; - var draftSnapshot = adventureCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, draftSnapshot, new PriceTier("USD", 1, 1000M)), context).Result; - - adventureCard = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(adventureCard, draftSnapshot, new Tag("new pricing")), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - // ADVENTURE CARD SECOND SNAPSHOT - adventureCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureCard, new PriceSnapshotComponent(date.AddDays(30))), context).Result; - var secondSnapshot = adventureCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("USD", 1, 7M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("USD", 5, 4M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("USD", 10, 3M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("CAD", 1, 6M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("CAD", 5, 3M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("CAD", 10, 2M)), context).Result; - adventureCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureCard, secondSnapshot, new PriceTier("EUR", 1, 1M)), context).Result; - - adventureCard = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(adventureCard, secondSnapshot, new Tag("future pricing")), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - readyForApprovalSnapshot?.SetComponent(new ApprovalComponent(context.GetPolicy().ReadyForApproval)); - firstSnapshot?.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - secondSnapshot?.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - - this._persistEntityPipeline.Run(new PersistEntityArgument(adventureCard), context).Wait(); - } - - /// - /// Creates the variants card. - /// - /// The book. - /// The context. - private void CreateVariantsCard(PriceBook book, CommercePipelineExecutionContext context) - { - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - var date = DateTimeOffset.UtcNow; - - // ADVENTURE VARIANTS CARD - var adventureVariantsCard = this._addPriceCardPipeline.Run(new AddPriceCardArgument(book, "AdventureVariantsPriceCard"), context).Result; - - // READY FOR APPROVAL SNAPSHOT - adventureVariantsCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureVariantsCard, new PriceSnapshotComponent(date.AddMinutes(-10))), context).Result; - var readyForApprovalSnapshot = adventureVariantsCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, readyForApprovalSnapshot, new PriceTier("USD", 1, 2000M)), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - // FIRST APPROVED SNAPSHOT - adventureVariantsCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureVariantsCard, new PriceSnapshotComponent(date.AddHours(-1))), context).Result; - var firstSnapshot = adventureVariantsCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("USD", 1, 9M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("USD", 5, 6M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("USD", 10, 3M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("CAD", 1, 7M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("CAD", 5, 4M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("CAD", 10, 2M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, firstSnapshot, new PriceTier("EUR", 1, 2M)), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - // DRAFT SNAPSHOT - adventureVariantsCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureVariantsCard, new PriceSnapshotComponent(date)), context).Result; - var draftSnapshot = adventureVariantsCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, draftSnapshot, new PriceTier("USD", 1, 1000M)), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - // SECOND APPROVED SNAPSHOT - adventureVariantsCard = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(adventureVariantsCard, new PriceSnapshotComponent(date.AddDays(30))), context).Result; - var secondSnapshot = adventureVariantsCard.Snapshots.FirstOrDefault(s => s.Id.Equals(context.CommerceContext.Models.OfType().FirstOrDefault()?.PriceSnapshotId, StringComparison.OrdinalIgnoreCase)); - - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("USD", 1, 8M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("USD", 5, 4M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("USD", 10, 2M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("CAD", 1, 7M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("CAD", 5, 3M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("CAD", 10, 1M)), context).Result; - adventureVariantsCard = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(adventureVariantsCard, secondSnapshot, new PriceTier("EUR", 1, 2M)), context).Result; - - context.CommerceContext.Models.RemoveAll(m => m is PriceSnapshotAdded || m is PriceTierAdded); - - readyForApprovalSnapshot?.SetComponent(new ApprovalComponent(context.GetPolicy().ReadyForApproval)); - firstSnapshot?.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - secondSnapshot?.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(adventureVariantsCard), context).Wait(); - } - - /// - /// Creates the tags card. - /// - /// The book. - /// The context. - private void CreateTagsCard(PriceBook book, CommercePipelineExecutionContext context) - { - // ADVENTURE TAGS CARD - var card = this._addPriceCardPipeline.Run(new AddPriceCardArgument(book, "AdventureTagsPriceCard"), context).Result; - - // ADVENTURE TAGS CARD FIRST SNAPSHOT - card = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(card, new PriceSnapshotComponent(DateTimeOffset.UtcNow)), context).Result; - var firstSnapshot = card.Snapshots.FirstOrDefault(); - - // ADVENTURE TAGS CARD FIRST SNAPSHOT TIERS - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, firstSnapshot, new PriceTier("USD", 1, 250M)), context).Result; - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, firstSnapshot, new PriceTier("USD", 5, 200M)), context).Result; - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, firstSnapshot, new PriceTier("CAD", 1, 251M)), context).Result; - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, firstSnapshot, new PriceTier("CAD", 5, 201M)), context).Result; - - // ADVENTURE TAGS CARD FIRST SNAPSHOT TAGS - card = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(card, firstSnapshot, new Tag("adventure works")), context).Result; - card = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(card, firstSnapshot, new Tag("adventure works 2")), context).Result; - card = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(card, firstSnapshot, new Tag("common")), context).Result; - - // ADVENTURE TAGS CARD SECOND SNAPSHOT - card = this._addPriceSnapshotPipeline.Run(new PriceCardSnapshotArgument(card, new PriceSnapshotComponent(DateTimeOffset.UtcNow.AddSeconds(1))), context).Result; - var secondSnapshot = card.Snapshots.FirstOrDefault(s => !s.Id.Equals(firstSnapshot?.Id)); - - // ADVENTURE TAGS CARD SECOND SNAPSHOT TIERS - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, secondSnapshot, new PriceTier("USD", 1, 150M)), context).Result; - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, secondSnapshot, new PriceTier("USD", 5, 100M)), context).Result; - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, secondSnapshot, new PriceTier("CAD", 1, 101M)), context).Result; - card = this._addPriceTierPipeline.Run(new PriceCardSnapshotTierArgument(card, secondSnapshot, new PriceTier("CAD", 5, 151M)), context).Result; - - // ADVENTURE TAGS CARD SECOND SNAPSHOT TAGS - card = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(card, secondSnapshot, new Tag("adventure works variants")), context).Result; - card = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(card, secondSnapshot, new Tag("adventure works variants 2")), context).Result; - card = this._addPriceSnapshotTagPipeline.Run(new PriceCardSnapshotTagArgument(card, secondSnapshot, new Tag("common")), context).Result; - - // ADVENTURE TAGS CARD APPROVAl COMPONENT - card.Snapshots.ForEach(s => - { - s.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - }); - this._persistEntityPipeline.Run(new PersistEntityArgument(card), context).Wait(); - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs deleted file mode 100644 index 3ffc249d..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs +++ /dev/null @@ -1,1306 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Coupons; - using Sitecore.Commerce.Plugin.Fulfillment; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Promotions; - using Sitecore.Commerce.Plugin.Rules; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps promotions for the AdventureWorks sample environment. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.InitializeEnvironmentPromotionsBlock)] - public class InitializeEnvironmentPromotionsBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - private readonly IAddPromotionBookPipeline _addBookPipeline; - private readonly IAddPromotionPipeline _addPromotionPipeline; - private readonly IAddQualificationPipeline _addQualificationPipeline; - private readonly IAddBenefitPipeline _addBenefitPipeline; - private readonly IAddPrivateCouponPipeline _addPrivateCouponPipeline; - private readonly IAddPromotionItemPipeline _addPromotionItemPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. - /// The add book pipeline. - /// The add promotion pipeline. - /// The add qualification pipeline. - /// The add benefit pipeline. - /// The add private coupon pipeline. - /// The add promotion item pipeline. - public InitializeEnvironmentPromotionsBlock( - IPersistEntityPipeline persistEntityPipeline, - IAddPromotionBookPipeline addBookPipeline, - IAddPromotionPipeline addPromotionPipeline, - IAddQualificationPipeline addQualificationPipeline, - IAddBenefitPipeline addBenefitPipeline, - IAddPrivateCouponPipeline addPrivateCouponPipeline, - IAddPromotionItemPipeline addPromotionItemPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - this._addBookPipeline = addBookPipeline; - this._addPromotionPipeline = addPromotionPipeline; - this._addQualificationPipeline = addQualificationPipeline; - this._addBenefitPipeline = addBenefitPipeline; - this._addPrivateCouponPipeline = addPrivateCouponPipeline; - this._addPromotionItemPipeline = addPromotionItemPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override async Task Run(string arg, CommercePipelineExecutionContext context) - { - var artifactSet = "Environment.AdventureWorks.Promotions-1.0"; - - // Check if this environment has subscribed to this Artifact Set - if (!context.GetPolicy() - .InitialArtifactSets.Contains(artifactSet)) - { - return arg; - } - - context.Logger.LogInformation($"{this.Name}.InitializingArtifactSet: ArtifactSet={artifactSet}"); - - var book = - await this._addBookPipeline.Run( - new AddPromotionBookArgument("AdventureWorksPromotionBook") - { - DisplayName = "Adventure Works", - Description = "This is the Adventure Works promotion book." - }, - context); - - this.CreateCartFreeShippingPromotion(book, context); - this.CreateCartExclusive5PctOffCouponPromotion(book, context); - this.CreateCartExclusive5OffCouponPromotion(book, context); - this.CreateCartExclusiveGalaxyPromotion(book, context); - this.CreateCart15PctOffCouponPromotion(book, context); - this.CreateDisabledPromotion(book, context); - - var date = DateTimeOffset.UtcNow; - this.CreateCart10PctOffCouponPromotion(book, context, date); - System.Threading.Thread.Sleep(1); //// TO ENSURE CREATING DATE IS DIFFERENT BETWEEN THESE TWO PROMOTIONS - this.CreateCart10OffCouponPromotion(book, context, date); - - this.CreateLineSaharaPromotion(book, context); - this.CreateLineSahara5OffPromotion(book, context); - this.CreateLineExclusiveAlpinePromotion(book, context); - this.CreateLineExclusive20PctOffCouponPromotion(book, context); - this.CreateLineExclusive20OffCouponPromotion(book, context); - this.CreateLine5PctOffCouponPromotion(book, context); - this.CreateLine5OffCouponPromotion(book, context); - - this.CreateSamplePrivateCouponPromotion(book, context); - - return arg; - } - - #region Cart's Promotions - - /// - /// Creates cart free shipping promotion. - /// - /// The book. - /// The context. - private void CreateCartFreeShippingPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "CartFreeShippingPromotion", DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddYears(1), "Free Shipping", "Free Shipping") - { - DisplayName = "Free Shipping", - Description = "Free shipping when Cart subtotal of $100 or more" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartSubtotalCondition, - Name = CartsConstants.Conditions.CartSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "100", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = FulfillmentConstants.Conditions.CartHasFulfillmentCondition, - Name = FulfillmentConstants.Conditions.CartHasFulfillmentCondition, - Properties = new List() - }), - context).Result; - - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = FulfillmentConstants.Actions.CartFreeShippingAction, - Name = FulfillmentConstants.Actions.CartFreeShippingAction - }), - context).Wait(); - - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context); - } - - /// - /// Creates cart exclusive 5 percent off coupon promotion. - /// - /// The book. - /// The context. - private void CreateCartExclusive5PctOffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Cart5PctOffExclusiveCouponPromotion", DateTimeOffset.UtcNow.AddDays(-2), DateTimeOffset.UtcNow.AddYears(1), "5% Off Cart (Exclusive Coupon)", "5% Off Cart (Exclusive Coupon)") - { - IsExclusive = true, - DisplayName = "5% Off Cart (Exclusive Coupon)", - Description = "5% off Cart with subtotal of $10 or more (Exclusive Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Name = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "10", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "5", DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNEC5P"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates the cart exclusive5 off coupon promotion. - /// - /// The book. - /// The context. - private void CreateCartExclusive5OffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Cart5OffExclusiveCouponPromotion", DateTimeOffset.UtcNow.AddDays(-3), DateTimeOffset.UtcNow.AddYears(1), "$5 Off Cart (Exclusive Coupon)", "$5 Off Cart (Exclusive Coupon)") - { - IsExclusive = true, - DisplayName = "$5 Off Cart (Exclusive Coupon)", - Description = "$5 off Cart with subtotal of $10 or more (Exclusive Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Name = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "10", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalAmountOffAction, - Name = CartsConstants.Actions.CartSubtotalAmountOffAction, - Properties = new List - { - new PropertyModel { Name = "AmountOff", Value = "5", DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNEC5A"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = promotion.Name, - DisplayName = promotion.DisplayName, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = $"{promotion.Name}-{Code}", - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates cart exclusive galaxy promotion. - /// - /// The book. - /// The context. - private void CreateCartExclusiveGalaxyPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "CartGalaxyTentExclusivePromotion", DateTimeOffset.UtcNow.AddDays(-4), DateTimeOffset.UtcNow.AddYears(1), "Galaxy Tent 50% Off Cart (Exclusive)", "Galaxy Tent 50% Off Cart (Exclusive)") - { - IsExclusive = true, - DisplayName = "Galaxy Tent 50% Off Cart (Exclusive)", - Description = "50% off Cart when buying Galaxy Tent (Exclusive)" - }, - context).Result; - - promotion = this._addPromotionItemPipeline.Run( - new PromotionItemArgument( - promotion, - "Adventure Works Catalog|AW535-11|"), - context).Result; - - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "50", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Wait(); - - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - } - - /// - /// Creates cart 15 percent off coupon promotion. - /// - /// The book. - /// The context. - private void CreateCart15PctOffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Cart15PctOffCouponPromotion", DateTimeOffset.UtcNow.AddDays(-5), DateTimeOffset.UtcNow.AddYears(1), "15% Off Cart (Coupon)", "15% Off Cart (Coupon)") - { - DisplayName = "15% Off Cart (Coupon)", - Description = "15% off Cart with subtotal of $50 or more (Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartSubtotalCondition, - Name = CartsConstants.Conditions.CartSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "50", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "15", DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNC15P"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates a sample promotion making use of private coupons - /// - /// The book. - /// The context. - private void CreateSamplePrivateCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = this._addPromotionPipeline.Run( - new AddPromotionArgument( - book, "SamplePrivateCouponPromotion", DateTimeOffset.UtcNow.AddDays(-5), DateTimeOffset.UtcNow.AddYears(1), "Sample Private Coupon Promotion", "Sample Private Coupon Promotion") - { - DisplayName = "Sample Private Coupon Promotion", - Description = "Sample Private Coupon Promotion" - }, - context).Result; - - promotion = this._addPrivateCouponPipeline.Run(new AddPrivateCouponArgument(promotion, "SPCP-", "-22", 15), context).Result; - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "SingleUseCouponCode"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List { new LimitUsagesPolicy { LimitCount = 1 } } - }), - context).Wait(); - - } - - /// - /// Creates the cart10 PCT off coupon promotion. - /// - /// The book. - /// The context. - /// The date. - private void CreateCart10PctOffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context, DateTimeOffset date) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Cart10PctOffCouponPromotion", date, date.AddYears(1), "10% Off Cart (Coupon)", "10% Off Cart (Coupon)") - { - DisplayName = "10% Off Cart (Coupon)", - Description = "10% off Cart with subtotal of $50 or more (Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartSubtotalCondition, - Name = CartsConstants.Conditions.CartSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "50", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "10", DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNC10P"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates the cart10 off coupon promotion. - /// - /// The book. - /// The context. - /// The date. - private void CreateCart10OffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context, DateTimeOffset date) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Cart10OffCouponPromotion", date, date.AddYears(1), "$10 Off Cart (Coupon)", "$10 Off Cart (Coupon)") - { - DisplayName = "$10 Off Cart (Coupon)", - Description = "$10 off Cart with subtotal of $50 or more (Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartSubtotalCondition, - Name = CartsConstants.Conditions.CartSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "50", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalAmountOffAction, - Name = CartsConstants.Actions.CartSubtotalAmountOffAction, - Properties = new List - { - new PropertyModel { Name = "AmountOff", Value = "10", DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context); - - const string Code = "RTRNC10A"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context); - } - - /// - /// Creates the disabled promotion. - /// - /// The book. - /// The context. - private void CreateDisabledPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "DisabledPromotion", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(1), "Disabled", "Disabled") - { - DisplayName = "Disabled", - Description = "Disabled" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartSubtotalCondition, - Name = CartsConstants.Conditions.CartSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "5", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "100", DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new DisabledPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context); - } - - #endregion - - #region Line's Promotions - - /// - /// Creates line sahara promotion. - /// - /// The book. - /// The context. - private void CreateLineSaharaPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "LineSaharaJacketPromotion", DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddYears(1), "Sahara Jacket 50% Off Item", "Sahara Jacket 50% Off Item") - { - DisplayName = "Sahara Jacket 50% Off Item", - Description = "50% off the Sahara Jacket item" - }, - context).Result; - - promotion = this._addPromotionItemPipeline.Run( - new PromotionItemArgument( - promotion, - "Adventure Works Catalog|AW114-06|"), - context).Result; - - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartItemSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartItemSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "50", IsOperator = false, DisplayType = "System.Decimal" }, - new PropertyModel { Name = "TargetItemId", Value = "Adventure Works Catalog|AW114-06|", IsOperator = false, DisplayType = "System.String" } - } - }), - context).Wait(); - - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - } - - /// - /// Creates the line sahara5 off promotion. - /// - /// The book. - /// The context. - private void CreateLineSahara5OffPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "LineSaharaJacket5OffPromotion", DateTimeOffset.UtcNow.AddDays(-2), DateTimeOffset.UtcNow.AddYears(1), "Sahara Jacket $5 Off Item", "Sahara Jacket $5 Off Item") - { - DisplayName = "Sahara Jacket $5 Off Item", - Description = "$5 off the Sahara Jacket item" - }, - context).Result; - - promotion = this._addPromotionItemPipeline.Run(new PromotionItemArgument(promotion, "Adventure Works Catalog|AW114-06|"), context).Result; - - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartItemSubtotalAmountOffAction, - Name = CartsConstants.Actions.CartItemSubtotalAmountOffAction, - Properties = new List - { - new PropertyModel { Name = "AmountOff", Value = "5", IsOperator = false, DisplayType = "System.Decimal" }, - new PropertyModel { Name = "TargetItemId", Value = "Adventure Works Catalog|AW114-06|", IsOperator = false, DisplayType = "System.String" } - } - }), - context).Wait(); - - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - } - - /// - /// Creates the line alpine parka exclusive promotion. - /// - /// The book. - /// The context. - private void CreateLineExclusiveAlpinePromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "LineAlpineParkaExclusivePromotion", DateTimeOffset.UtcNow.AddDays(-2), DateTimeOffset.UtcNow.AddYears(1), "Alpine Parka 50% Off Item (Exclusive)", "Alpine Parka 50% Off Item (Exclusive)") - { - DisplayName = "Alpine Parka 50% Off Item (Exclusive)", - Description = "50% off the Alpine Parka item (Exclusive)" - }, - context).Result; - - promotion = this._addPromotionItemPipeline.Run( - new PromotionItemArgument( - promotion, - "Adventure Works Catalog|AW188-06|"), - context).Result; - - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartItemSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartItemSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "50", IsOperator = false, DisplayType = "System.Decimal" }, - new PropertyModel { Name = "TargetItemId", Value = "Adventure Works Catalog|AW188-06|", IsOperator = false, DisplayType = "System.String" } - } - }), - context).Wait(); - - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - } - - /// - /// Creates line exclusive 20 percent off coupon promotion. - /// - /// The book. - /// The context. - private void CreateLineExclusive20PctOffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Line20PctOffExclusiveCouponPromotion", DateTimeOffset.UtcNow.AddDays(-3), DateTimeOffset.UtcNow.AddYears(1), "20% Off Item (Exclusive Coupon)", "20% Off Item (Exclusive Coupon)") - { - IsExclusive = true, - DisplayName = "20% Off Item (Exclusive Coupon)", - Description = "20% off any item with subtotal of $50 or more (Exclusive Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Name = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "25", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartAnyItemSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartAnyItemSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "20", DisplayType = "System.Decimal" }, - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "25", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNEL20P"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates the line exclusive $20 off coupon promotion. - /// - /// The book. - /// The context. - private void CreateLineExclusive20OffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Line20OffExclusiveCouponPromotion", DateTimeOffset.UtcNow.AddDays(-4), DateTimeOffset.UtcNow.AddYears(1), "$20 Off Item (Exclusive Coupon)", "$20 Off Item (Exclusive Coupon)") - { - IsExclusive = true, - DisplayName = "$20 Off Item (Exclusive Coupon)", - Description = "$20 off any item with subtotal of $50 or more (Exclusive Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Name = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "25", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartAnyItemSubtotalAmountOffAction, - Name = CartsConstants.Actions.CartAnyItemSubtotalAmountOffAction, - Properties = new List - { - new PropertyModel { Name = "AmountOff", Value = "20", DisplayType = "System.Decimal" }, - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "25", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNEL20A"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = promotion.Name, - DisplayName = promotion.DisplayName, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = $"{promotion.Name}-{Code}", - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates line 5 percent off coupon promotion. - /// - /// The book. - /// The context. - private void CreateLine5PctOffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Line5PctOffCouponPromotion", DateTimeOffset.UtcNow.AddDays(-5), DateTimeOffset.UtcNow.AddYears(1), "5% Off Item (Coupon)", "5% Off Item (Coupon)") - { - DisplayName = "5% Off Item (Coupon)", - Description = "5% off any item with subtotal of 10$ or more (Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Name = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "10", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartAnyItemSubtotalPercentOffAction, - Name = CartsConstants.Actions.CartAnyItemSubtotalPercentOffAction, - Properties = new List - { - new PropertyModel { Name = "PercentOff", Value = "5", DisplayType = "System.Decimal" }, - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "10", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNL5P"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - /// - /// Creates line 5 amount off coupon promotion. - /// - /// The book. - /// The context. - private void CreateLine5OffCouponPromotion(PromotionBook book, CommercePipelineExecutionContext context) - { - var promotion = - this._addPromotionPipeline.Run( - new AddPromotionArgument(book, "Line5OffCouponPromotion", DateTimeOffset.UtcNow.AddDays(-6), DateTimeOffset.UtcNow.AddYears(1), "$5 Off Item (Coupon)", "$5 Off Item (Coupon)") - { - DisplayName = "$5 Off Item (Coupon)", - Description = "$5 off any item with subtotal of $10 or more (Coupon)" - }, - context).Result; - - promotion = - this._addQualificationPipeline.Run( - new PromotionConditionModelArgument( - promotion, - new ConditionModel - { - ConditionOperator = "And", - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Name = CartsConstants.Conditions.CartAnyItemSubtotalCondition, - Properties = new List - { - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "10", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion = - this._addBenefitPipeline.Run( - new PromotionActionModelArgument( - promotion, - new ActionModel - { - Id = Guid.NewGuid().ToString(), - LibraryId = CartsConstants.Actions.CartAnyItemSubtotalAmountOffAction, - Name = CartsConstants.Actions.CartAnyItemSubtotalAmountOffAction, - Properties = new List - { - new PropertyModel { Name = "AmountOff", Value = "5", DisplayType = "System.Decimal" }, - new PropertyModel { IsOperator = true, Name = "Operator", Value = "Sitecore.Commerce.Plugin.Rules.DecimalGreaterThanOrEqualToOperator", DisplayType = "Sitecore.Framework.Rules.IBinaryOperator`2[[System.Decimal],[System.Decimal]], Sitecore.Framework.Rules.Abstractions" }, - new PropertyModel { Name = "Subtotal", Value = "10", IsOperator = false, DisplayType = "System.Decimal" } - } - }), - context).Result; - - promotion.SetPolicy(new CouponRequiredPolicy()); - promotion.SetComponent(new ApprovalComponent(context.GetPolicy().Approved)); - this._persistEntityPipeline.Run(new PersistEntityArgument(promotion), context).Wait(); - - const string Code = "RTRNL5A"; - this._persistEntityPipeline.Run( - new PersistEntityArgument( - new Coupon - { - Id = $"{CommerceEntity.IdPrefix()}{Code}", - Code = Code, - Name = Code, - DisplayName = Code, - DateCreated = DateTimeOffset.UtcNow, - DateUpdated = DateTimeOffset.UtcNow, - Promotion = new EntityReference { EntityTarget = promotion.Id }, - CouponType = CouponsConstants.KnownCouponTypeNames.PublicCouponTypeName, - FriendlyId = Code, - Components = new List - { - new ListMembershipsComponent - { - Memberships = new List - { - CommerceEntity.ListName(), - string.Format(context.GetPolicy().PromotionCoupons, promotion.FriendlyId), - string.Format(context.GetPolicy().PublicCoupons, promotion.FriendlyId) - } - } - }, - Policies = new List - { - new LimitUsagesPolicy - { - LimitCount = 100 - } - } - }), - context).Wait(); - } - - #endregion - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentRegionsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentRegionsBlock.cs deleted file mode 100644 index d5f30259..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentRegionsBlock.cs +++ /dev/null @@ -1,106 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Threading.Tasks; - using System.Collections.Generic; - using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps an environments Regions. - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.InitializeEnvironmentRegionsBlock)] - public class InitializeEnvironmentRegionsBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The find entity pipeline. - /// - public InitializeEnvironmentRegionsBlock(IPersistEntityPipeline persistEntityPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public async override Task Run(string arg, CommercePipelineExecutionContext context) - { - var artifactSet = "Environment.Regions-1.0"; - - //Check if this environment has subscribed to this Artifact Set - if (!context.GetPolicy() - .InitialArtifactSets.Contains(artifactSet)) - { - return arg; - } - - context.Logger.LogInformation($"{this.Name}.InitializingArtifactSet: ArtifactSet={artifactSet}"); - - var result = await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Country - { - Id = $"{CommerceEntity.IdPrefix()}USA", - Name = "United States", - IsoCode2 = "US", - IsoCode3 = "USA", - Components = new List - { - new ListMembershipsComponent { Memberships = new List { "Countries" } } - }, - AddressFormat = "1" - }), context); - - - result = await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Country - { - Id = $"{CommerceEntity.IdPrefix()}CAN", - Name = "Canada", - IsoCode2 = "CA", - IsoCode3 = "CAN", - Components = new List - { - new ListMembershipsComponent { Memberships = new List { "Countries" } } - }, - AddressFormat = "1" - }), context); - - result = await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Country - { - Id = $"{CommerceEntity.IdPrefix()}DNK", - Name = "Denmark", - IsoCode2 = "DK", - IsoCode3 = "DNK", - Components = new List - { - new ListMembershipsComponent { Memberships = new List { "Countries" } } - }, - AddressFormat = "1" - }), context); - - return arg; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs deleted file mode 100644 index 18443046..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs +++ /dev/null @@ -1,2387 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Collections.Generic; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Availability; - using Sitecore.Commerce.Plugin.Catalog; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Pricing; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps sellable items the AdventureWorks sample environment. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.BootstrapAwSellableItemsBlock)] - public class InitializeEnvironmentSellableItemsBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The find entity pipeline. - /// - public InitializeEnvironmentSellableItemsBlock(IPersistEntityPipeline persistEntityPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override Task Run(string arg, CommercePipelineExecutionContext context) - { - var artifactSet = "Environment.AdventureWorks.SellableItems-1.0"; - - // Check if this environment has subscribed to this Artifact Set - if (!context.GetPolicy() - .InitialArtifactSets.Contains(artifactSet)) - { - return Task.FromResult(arg); - } - - context.Logger.LogInformation($"{this.Name}.InitializingArtifactSet: ArtifactSet={artifactSet}"); - - - // CS PRODUCTS - this.BootstrapCsGiftCards(context); - this.BootstrapCsSleepingBags(context); - this.BootstrapCsBoots(context); - this.BootstrapCsTents(context); - this.BootstrapCsParkas(context); - this.BootstrapCsPants(context); - this.BootstrapCsHarnesses(context); - this.BootstrapCsCrampos(context); - this.BootstrapCsCarabines(context); - this.BootstrapCsRockshoes(context); - this.BootstrapCsBackpacks(context); - this.BootstrapCsShirts(context); - this.BootstrapCsSupplies(context); - - return Task.FromResult(arg); - } - - /// - /// Bootstraps the cs gift cards. - /// - /// The context. - protected virtual void BootstrapCsGiftCards(CommercePipelineExecutionContext context) - { - var giftCard = new SellableItem - { - Id = $"{CommerceEntity.IdPrefix()}22565422120", - Name = "Default GiftCard", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 0M), new Money("CAD", 0M) }) - }, - Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "010", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 10M), new Money("CAD", 11M) }) - } - }, - new ItemVariationComponent - { - Id = "020", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 20M), new Money("CAD", 21M) }) - } - }, - new ItemVariationComponent - { - Id = "025", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 25M), new Money("CAD", 26M) }) - } - }, - new ItemVariationComponent - { - Id = "050", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - } - }, - new ItemVariationComponent - { - Id = "100", - Name = "Gift Card", - Policies = new List - { - new AvailabilityAlwaysPolicy(), - new ListPricingPolicy(new List { new Money("USD", 100M), new Money("CAD", 101M) }) - } - } - } - } - } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(giftCard), context).Wait(); - } - - /// - /// Bootstraps the cs sleeping bags. - /// - /// The context. - protected virtual void BootstrapCsSleepingBags(CommercePipelineExecutionContext context) - { - var sleepingBag = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "3", - Name = "Big Sur (Blue)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 220M), new Money("CAD", 221M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 220M), new Money("CAD", 221M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW200-12", - Name = "Big Sur" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(sleepingBag), context).Wait(); - - var sleepingbag2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "4", - Name = "Day Hike (Blue)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 212M), new Money("CAD", 213M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 212M), new Money("CAD", 213M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW210-12", - Name = "Day Hike" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(sleepingbag2), context).Wait(); - - var sleepingBag3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "2", - Name = "Polar Star (Black)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 320M), new Money("CAD", 321M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW310-12", - Name = "Polar Star", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 320M), new Money("CAD", 321M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(sleepingBag3), context).Wait(); - - var sleepingBag4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "1", - Name = "North Face Sunspot (Red)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 402M), - new Money("CAD", 403M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW390-12", - Name = "North Face Sunspot", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 402M), new Money("CAD", 403M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(sleepingBag4), context).Wait(); - } - - /// - /// Bootstraps the cs boots. - /// - /// The context. - protected virtual void BootstrapCsBoots(CommercePipelineExecutionContext context) - { - var boot = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "9", - Name = "Dunes (Light green)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 123M), - new Money("CAD", 124M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 123M), new Money("CAD", 124M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW074-04", - Name = "Dunes" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(boot), context).Wait(); - - var boot2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "6", - Name = "Rockies (Green)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 85M), new Money("CAD", 86M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "7", - Name = "Rockies (Gray)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 85M), new Money("CAD", 86M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW078-04", - Name = "Rockies", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 85M), new Money("CAD", 86M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(boot2), context).Wait(); - - var boot3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "8", - Name = "Sierras (Dark brown)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 90M), new Money("CAD", 91M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 90M), new Money("CAD", 91M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW087-04", - Name = "Sierras" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(boot3), context).Wait(); - - var boot4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "5", - Name = "Everglades (Brown)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 105M), new Money("CAD", 106M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW098-04", - Name = "Everglades", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 105M), new Money("CAD", 106M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(boot4), context).Wait(); - } - - /// - /// Bootstraps the cs tents. - /// - /// The context. - protected virtual void BootstrapCsTents(CommercePipelineExecutionContext context) - { - var tent = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "16", - Name = "Scirocco (Black)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "17", - Name = "Scirocco (Grey)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "18", - Name = "Scirocco (Purple)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW190-11", - Name = "Scirocco" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(tent), context).Wait(); - - var tent2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "14", - Name = "Aptos (Green)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 340M), new Money("CAD", 341M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "15", - Name = "Aptos (Black)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 340M), new Money("CAD", 341M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW335-11", - Name = "Aptos", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 340M), new Money("CAD", 341M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(tent2), context).Wait(); - - var tent3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "10", - Name = "Starlight (Black)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 425M), new Money("CAD", 426M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "11", - Name = "Starlight (Grey)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 425M), new Money("CAD", 426M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW425-11", - Name = "Starlight", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 425M), new Money("CAD", 426M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(tent3), context).Wait(); - - var tent4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "12", - Name = "Galaxy (Beige)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 535M), new Money("CAD", 536M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "13", - Name = "Galaxy (Purple)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 535M), new Money("CAD", 536M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Id = $"{CommerceEntity.IdPrefix()}AW535-11", - Name = "Galaxy", - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 535M), new Money("CAD", 536M) }) } - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(tent4), context).Wait(); - } - - /// - /// Bootstraps the cs parkas. - /// - /// The context. - protected virtual void BootstrapCsParkas(CommercePipelineExecutionContext context) - { - var parka = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent(), - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "23", - Name = "Sahara (Green)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 120M), new Money("CAD", 121M) }) - } - }, - new ItemVariationComponent - { - Id = "24", - Name = "Sahara (Purple)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 120M), new Money("CAD", 121M) }) - } - } - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 120M), new Money("CAD", 121M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW114-06", - Name = "Sahara" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(parka), context).Wait(); - - var parka2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent(), - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "25", - Name = "Crystal (Purple)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 125M), new Money("CAD", 126M) }) - } - }, - new ItemVariationComponent - { - Id = "26", - Name = "Crystal (Blue)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 125M), new Money("CAD", 126M) }) - } - } - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 125M), new Money("CAD", 126M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW125-09", - Name = "Crystal" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(parka2), context).Wait(); - - var parka3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent(), - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "19", - Name = "Alpine (Red)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) - } - }, - new ItemVariationComponent - { - Id = "20", - Name = "Alpine (Red)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) - } - }, - new ItemVariationComponent - { - Id = "21", - Name = "Alpine (Black)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) - } - }, - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 190M), new Money("CAD", 191M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW188-06", - Name = "Alpine" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(parka3), context).Wait(); - - var parka4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent(), - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "22", - Name = "Campos (Blue)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 250M), new Money("CAD", 251M) }) - } - } - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 250M), new Money("CAD", 251M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW250-06", - Name = "Campos" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(parka4), context).Wait(); - } - - /// - /// Bootstraps the cs pants. - /// - /// The context. - protected virtual void BootstrapCsPants(CommercePipelineExecutionContext context) - { - var pant = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "27", - Name = "Women's 4 pocket pant. (Green, Size 2)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "28", - Name = "Women's 4 pocket pant. (Beige, Size 2)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "37", - Name = "Women's 4 pocket pant. (Green, Size 16)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "38", - Name = "Women's 4 pocket pant. (Beige, Size 16)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW032-01", - Name = "Women's 4 pocket pant." - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(pant), context).Wait(); - - var pant2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "29", - Name = "Men's 8-pocket conversion pants. (Gray, Size 28)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 46M), new Money("CAD", 47M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "30", - Name = "Men's 8-pocket conversion pants. (Brown, Size 28)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 46M), new Money("CAD", 47M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "39", - Name = "Men's 8-pocket conversion pants. (Gray, Size 46)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 46M), new Money("CAD", 47M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "40", - Name = "Men's 8-pocket conversion pants. (Brown, Size 46)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 46M), new Money("CAD", 47M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 46M), new Money("CAD", 47M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW046-01", - Name = "Men's 8-pocket conversion pants." - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(pant2), context).Wait(); - - var pant3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "31", - Name = "Unisex drawstring pants. (Green, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "32", - Name = "Unisex drawstring pants. (Brown, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "41", - Name = "Unisex drawstring pants. (Green, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "42", - Name = "Unisex drawstring pants. (Brown, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "51", - Name = "Unisex drawstring pants. (Green, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "52", - Name = "Unisex drawstring pants. (Brown, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW048-01", - Name = "Unisex drawstring pants." - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(pant3), context).Wait(); - - var pant4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "33", - Name = "Unisex hiking pants (Green, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "34", - Name = "Unisex hiking pants (Beige, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "43", - Name = "Unisex hiking pants (Green, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "44", - Name = "Unisex hiking pants (Beige, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "53", - Name = "Unisex hiking pants (Green, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "54", - Name = "Unisex hiking pants (Beige, Size XXL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = new List { new ListPricingPolicy(new List { new Money("USD", 58M), new Money("CAD", 59M) }) }, - Id = $"{CommerceEntity.IdPrefix()}AW055-01", - Name = "Unisex hiking pants" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(pant4), context).Wait(); - } - - /// - /// Bootstraps the cs harnesses. - /// - /// The context. - protected virtual void BootstrapCsHarnesses(CommercePipelineExecutionContext context) - { - var harness = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "36", - Name = "Black Diamond Alpine Bod (Black)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 33M), new Money("CAD", 34M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 33M), new Money("CAD", 34M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW029-10", - Name = "Black Diamond Alpine Bod" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(harness), context).Wait(); - - var harness2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "35", - Name = "Black Diamond Bod (Assorted colors)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 33M), new Money("CAD", 34M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 33M), new Money("CAD", 34M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW032-10", - Name = "Black Diamond Bod" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(harness2), context).Wait(); - - var harness3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "37", - Name = "El Capitan (Blue)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 60M), new Money("CAD", 61M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 60M), new Money("CAD", 61M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW053-10", - Name = "El Capitan" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(harness3), context).Wait(); - - var harness4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "38", - Name = "Petzl Mercury (Assorted colors)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW072-10", - Name = "Petzl Mercury" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(harness4), context).Wait(); - } - - /// - /// Bootstraps the cs crampos. - /// - /// The context. - protected virtual void BootstrapCsCrampos(CommercePipelineExecutionContext context) - { - var crampon = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 109M), new Money("CAD", 110M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW109-15", - Name = "Wafflestomper" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(crampon), context).Wait(); - - var crampon2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 150M), new Money("CAD", 151M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW145-15", - Name = "Edgehugger" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(crampon2), context).Wait(); - - var crampon3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 149M), new Money("CAD", 150M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW149-15", - Name = "Glory Grip" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(crampon3), context).Wait(); - } - - /// - /// Bootstraps the cs carabines. - /// - /// The context. - protected virtual void BootstrapCsCarabines(CommercePipelineExecutionContext context) - { - var carabiner = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 14M), new Money("CAD", 15M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW014-08", - Name = "Petzl Spirit" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(carabiner), context).Wait(); - - var carabiner2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 10M), new Money("CAD", 11M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW007-08", - Name = "Black Diamond Quicksilver II" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(carabiner2), context).Wait(); - } - - /// - /// Bootstraps the cs rockshoes. - /// - /// The context. - protected virtual void BootstrapCsRockshoes(CommercePipelineExecutionContext context) - { - var rockshoe = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 135M), new Money("CAD", 136M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW125-05", - Name = "Plymouth" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(rockshoe), context).Wait(); - - var rockshoe2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 95M), new Money("CAD", 96M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW082-05", - Name = "Morro" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(rockshoe2), context).Wait(); - - var rockshoe3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 124M), new Money("CAD", 125M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW086-06", - Name = "Tuscany" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(rockshoe3), context).Wait(); - } - - /// - /// Bootstraps the cs backpacks. - /// - /// The context. - protected virtual void BootstrapCsBackpacks(CommercePipelineExecutionContext context) - { - var backpack = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "41", - Name = "University (Blau)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 155M), - new Money("CAD", 156M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 155M), new Money("CAD", 156M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW140-13", - Name = "University" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(backpack), context).Wait(); - - var backpack2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "42", - Name = "Pacific (Blue)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 151M), - new Money("CAD", 152M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 151M), new Money("CAD", 152M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW151-13", - Name = "Pacific" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(backpack2), context).Wait(); - - var backpack3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "43", - Name = "Conestoga (Red)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 184M), - new Money("CAD", 185M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 184M), new Money("CAD", 185M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW175-13", - Name = "Conestoga" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(backpack3), context).Wait(); - - var backpack4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "39", - Name = "Aces (Blue)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 325M), - new Money("CAD", 326M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "40", - Name = "Aces (Black)", - Policies = new List - { - new ListPricingPolicy(new List - { - new Money("USD", 325M), - new Money("CAD", 326M) - }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 325M), new Money("CAD", 326M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW325-13", - Name = "Aces" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(backpack4), context).Wait(); - } - - /// - /// Bootstraps the cs shirts. - /// - /// The context. - protected virtual void BootstrapCsShirts(CommercePipelineExecutionContext context) - { - var shirt = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "44", - Name = "Women's woven tee (Blue, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "45", - Name = "Women's woven tee (Beige, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "46", - Name = "Women's woven tee (Green, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M), new Money("EUR", 33M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "54", - Name = "Women's woven tee (Blue, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "55", - Name = "Women's woven tee (Beige, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M), new Money("EUR", 32M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "56", - Name = "Women's woven tee (Green, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "64", - Name = "Women's woven tee (Blue, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 35M), new Money("CAD", 36M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW029-03", - Name = "Women's woven tee" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(shirt), context).Wait(); - - var shirt2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "51", - Name = "Men's button-down (Blue, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "52", - Name = "Men's button-down (Red, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "53", - Name = "Men's button-down (Beige, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "61", - Name = "Men's button-down (Blue, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "62", - Name = "Men's button-down (Red ,Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "63", - Name = "Men's button-down (Beige, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "71", - Name = "Men's button-down (Blue, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 48M), new Money("CAD", 49M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW042-03", - Name = "Men's button-down" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(shirt2), context).Wait(); - - var shirt3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "47", - Name = "Men's loose-weave polo (Red, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "48", - Name = "Men's loose-weave polo (Blue, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "49", - Name = "Men's loose-weave polo (White, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "50", - Name = "Men's loose-weave polo (Beige, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "57", - Name = "Men's loose-weave polo (Red, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "58", - Name = "Men's loose-weave polo (Blue, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "59", - Name = "Men's loose-weave polo (White, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "60", - Name = "Men's loose-weave polo (Beige, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "67", - Name = "Men's loose-weave polo (Red, Size XXL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "68", - Name = "Men's loose-weave polo (Blue, Size XXL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "69", - Name = "Men's loose-weave polo (White, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "70", - Name = "Men's loose-weave polo (Beige, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 45M), new Money("CAD", 46M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW045-03", - Name = "Men's loose-weave polo" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(shirt3), context).Wait(); - - var shirt4 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new ItemVariationsComponent - { - ChildComponents = new List - { - new ItemVariationComponent - { - Id = "54", - Name = "Unisex long-sleeve button-down (Green, Size S)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "55", - Name = "Unisex long-sleeve button-down (Beige, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "64", - Name = "Unisex long-sleeve button-down (Green, Size M)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "65", - Name = "Unisex long-sleeve button-down (Beige, Size L)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 75M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "74", - Name = "Unisex long-sleeve button-down (Green, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - }, - new ItemVariationComponent - { - Id = "75", - Name = "Unisex long-sleeve button-down (Beige, Size XL)", - Policies = new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - ChildComponents = new List - { - new PhysicalItemComponent() - } - } - } - } - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 75M), new Money("CAD", 76M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW075-03", - Name = "Unisex long-sleeve button-down" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(shirt4), context).Wait(); - } - - /// - /// Bootstraps the cs supplies. - /// - /// The context. - protected virtual void BootstrapCsSupplies(CommercePipelineExecutionContext context) - { - var supply = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 44.75M), new Money("CAD", 45.75M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW051-14", - Name = "Wolfgang" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(supply), context).Wait(); - - var supply2 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 59M), new Money("CAD", 60M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW475-14", - Name = "Scoutpride" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(supply2), context).Wait(); - - var supply3 = new SellableItem - { - Components = new List - { - new CatalogComponent { Name = "Adventure Works Catalog" }, - new ListMembershipsComponent - { - Memberships = new List { CommerceEntity.ListName() } - }, - new PhysicalItemComponent() - }, - Policies = - new List - { - new ListPricingPolicy(new List { new Money("USD", 9M), new Money("CAD", 10M) }) - }, - Id = $"{CommerceEntity.IdPrefix()}AW425-14", - Name = "Surelite" - }; - this._persistEntityPipeline.Run(new PersistEntityArgument(supply3), context).Wait(); - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentShopsBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentShopsBlock.cs deleted file mode 100644 index 5d9886cf..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/InitializeEnvironmentShopsBlock.cs +++ /dev/null @@ -1,245 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Threading.Tasks; - using System.Collections.Generic; - using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Shops; - using Sitecore.Commerce.Plugin.Tax; - using Sitecore.Framework.Pipelines; - using ManagedLists; - - /// - /// Defines a block which bootstraps shops for AdventureWorks Sample environment. - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.InitializeEnvironmentShopsBlock)] - public class InitializeEnvironmentShopsBlock : PipelineBlock - { - private readonly IPersistEntityPipeline _persistEntityPipeline; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The find entity pipeline. - /// - public InitializeEnvironmentShopsBlock(IPersistEntityPipeline persistEntityPipeline) - { - this._persistEntityPipeline = persistEntityPipeline; - } - - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// - public override async Task Run(string arg, CommercePipelineExecutionContext context) - { - var artifactSet = "Environment.Shops-1.0"; - - //Check if this environment has subscribed to this Artifact Set - if (!context.GetPolicy() - .InitialArtifactSets.Contains(artifactSet)) - { - return arg; - } - - context.Logger.LogInformation($"{this.Name}.InitializingArtifactSet: ArtifactSet={artifactSet}"); - - // Default Shop Entity - await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Shop - { - Id = $"{CommerceEntity.IdPrefix()}Storefront", - Name = "Storefront", - FriendlyId = "Storefront", - DisplayName = "Storefront", - //GeoZone = new GeoZone { Latitude = "100", Longitude = "100" }, - //TimeZone = "GMT-08:00", - //Languages = new List - // { - // "en-US", - // "en-CA", - // "fr-FR", - // "de-DE", - // "ja-JP" - // }, - //DefaultCurrency = "USD", - //DefaultCountry = new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" }, - //Countries = new List - // { - // new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" } - // }, - //DefaultLanguage = "en-US", - //Catalogs = new List - //{ - // new EntityReference { EntityTarget = "Adventure Works Catalog" } - //}, - //Policies = new List - //{ - // new GlobalTaxPolicy { PriceIncudesTax = false }, - // new TaxGroupPolicy { TaxGroup = "TaxUsa" } - //}, - Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, - //new OnlineShopComponent { ServiceUrl="http://localhost:5000" }, - //new ShopFinancialsComponent { - // LegalEntity = "LegalEntity2", - // DefaultCustomer = "Customer2", - // BusinessUnit = "BusinessUnit2", - // CostCenter = "CostCenter2", - // Department = "Department2" } - } - } - ), context); - - await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Shop - { - Id = $"{CommerceEntity.IdPrefix()}AwShopCanada", - Name = "AwShopCanada", - FriendlyId = "AwShopCanada", - DisplayName = "Adventure Works Canada", - //GeoZone = new GeoZone { Latitude = "100", Longitude = "100" }, - //TimeZone = "GMT-06:00", - //Languages = new List - // { - // "en-CA", - // "fr-FR" - // }, - //DefaultCurrency = "CAD", - //DefaultCountry = new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}CAD" }, - //Countries = new List - // { - // new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" }, - // new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}CAN" } - // }, - //DefaultLanguage = "en-CA", - //Catalogs = new List - //{ - // new EntityReference { EntityTarget = "Adventure Works Catalog" } - //}, - //Policies = new List - //{ - // new GlobalTaxPolicy { PriceIncudesTax = false }, - // new TaxGroupPolicy { TaxGroup = "TaxCan" } - //}, - Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, - //new OnlineShopComponent { ServiceUrl="http://localhost:5100" }, - //new ShopFinancialsComponent { - // LegalEntity = "LegalEntity1", - // DefaultCustomer = "Customer1", - // BusinessUnit = "BusinessUnit1", - // CostCenter = "CostCenter1", - // Department = "Department1" } - } - } - ), context); - - await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Shop - { - Id = $"{CommerceEntity.IdPrefix()}AwShopUsa", - Name = "AwShopUsa", - FriendlyId = "AwShopUsa", - DisplayName = "Adventure Works USA", - //GeoZone = new GeoZone { Latitude = "100", Longitude = "100" }, - //TimeZone = "GMT-08:00", - //Languages = new List - // { - // "en-US" - // }, - //DefaultCurrency = "USD", - //DefaultCountry = new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" }, - //Countries = new List - // { - // new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" } - // }, - //DefaultLanguage = "en-US", - //Catalogs = new List - //{ - // new EntityReference { EntityTarget = "Adventure Works Catalog" } - //}, - //Policies = new List - //{ - // new GlobalTaxPolicy { PriceIncudesTax = false }, - // new TaxGroupPolicy { TaxGroup = "TaxUsa" } - //}, - Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, - //new OnlineShopComponent { ServiceUrl="http://localhost:5200" }, - //new ShopFinancialsComponent { - // LegalEntity = "LegalEntity2", - // DefaultCustomer = "Customer2", - // BusinessUnit = "BusinessUnit2", - // CostCenter = "CostCenter2", - // Department = "Department2" } - } - } - ), context); - - await this._persistEntityPipeline.Run(new PersistEntityArgument( - new Shop - { - Id = $"{CommerceEntity.IdPrefix()}AwShopGermany", - Name = "AwShopGermany", - DisplayName = "Adventure Works Germany", - //GeoZone = new GeoZone { Latitude = "100", Longitude = "100" }, - //TimeZone = "GMT+01:00", - //Languages = new List - // { - // "de-DE", - // "en-US" - // }, - //DefaultCurrency = "Eur", - //DefaultCountry = new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" }, - //Countries = new List - // { - // new EntityReference { EntityTarget = $"{CommerceEntity.IdPrefix()}USA" } - // }, - //DefaultLanguage = "de-DE", - //Catalogs = new List - // { - // new EntityReference { EntityTarget = "Adventure Works Catalog" } - // }, - //Policies = new List - //{ - // new GlobalTaxPolicy { PriceIncudesTax = true }, - // new TaxGroupPolicy { TaxGroup = "TaxGermany" } - //}, - Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, - //new OnlineShopComponent { ServiceUrl = "http://localhost:5300" }, - //new ShopFinancialsComponent { - // LegalEntity = "LegalEntity3", - // DefaultCustomer = "Customer3", - // BusinessUnit = "BusinessUnit3", - // CostCenter = "CostCenter3", - // Department = "Department3" - //} - } - } - ), context); - - return arg; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/RegisteredPluginBlock.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/RegisteredPluginBlock.cs deleted file mode 100644 index 9b361ffc..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Pipelines/Blocks/RegisteredPluginBlock.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -// Defines the registered plugin block. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - using Sitecore.Commerce.Core; - using Sitecore.Framework.Pipelines; - - /// - /// Defines the registered plugin block. - /// - [PipelineDisplayName(AwConstants.Pipelines.Blocks.RegisteredPluginBlock)] - public class RegisteredPluginBlock : PipelineBlock, IEnumerable, CommercePipelineExecutionContext> - { - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The list of - /// - public override Task> Run(IEnumerable arg, CommercePipelineExecutionContext context) - { - if (arg == null) - { - return Task.FromResult(arg); - } - - var plugins = arg.ToList(); - PluginHelper.RegisterPlugin(this, plugins); - - return Task.FromResult(plugins.AsEnumerable()); - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ServiceCollectionExtensions.cs b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ServiceCollectionExtensions.cs deleted file mode 100644 index 0e429875..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Sitecore.Commerce.Plugin.AdventureWorks -{ - using Microsoft.Extensions.DependencyInjection; - - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Catalog.Cs; - using Sitecore.Commerce.Plugin.Coupons; - using Sitecore.Commerce.Plugin.Fulfillment; - using Sitecore.Commerce.Plugin.GiftCards; - using Sitecore.Commerce.Plugin.Inventory.Cs; - using Sitecore.Commerce.Plugin.Orders; - using Sitecore.Commerce.Plugin.Payments; - using Sitecore.Commerce.Plugin.Promotions; - using Sitecore.Commerce.Plugin.Tax; - using Sitecore.Framework.Pipelines.Definitions.Extensions; - - /// - /// The services extensions. - /// - public static class ServiceCollectionExtensions - { - /// - /// The configure cart pipelines. - /// - /// - /// The services. - /// - /// - /// The . - /// - public static IServiceCollection ConfigureCartPipelines(this IServiceCollection services) - { - services.Sitecore().Pipelines(config => config - .ConfigurePipeline(builder => builder - .Add() - .Add() - .Add() - .Add() - .Add() - .Add() - .Add() - .Add() - .Add()) - - .ConfigurePipeline(builder => builder - .Add() - .Add() - .Add() - .Add() - .Add() - .Add()) - - .ConfigurePipeline(builder => builder.Add().After())); - - return services; - } - - /// - /// The configure orders pipelines. - /// - /// - /// The services. - /// - /// - /// The . - /// - public static IServiceCollection ConfigureOrdersPipelines(this IServiceCollection services) - { - services.Sitecore().Pipelines(config => config - .ConfigurePipeline(builder => builder - .Add())); - - //.ConfigurePipeline(builder => builder.Add())); - - return services; - } - } -} diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/build.not b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/build.not deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/project.json b/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/project.json deleted file mode 100644 index efbd1e84..00000000 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/project.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "version": "1.0.2301", - "description": "The Sitecore Commerce Adventure Works Sample Plugin.", - "copyright": "© 2017 Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.", - "authors": [ - "Sitecore" - ], - "packOptions": { - "summary": "This package contains the Adventure Works Sample plugin for the Sitecore Commerce Engine.", - "tags": [ - "Sitecore", - "Commerce", - "Plugin", - "Sample", - "Example" - ], - "owners": [ - "Sitecore Corporation A/S" - ], - "releaseNotes": "release notes", - "iconUrl": "http://www.sitecore.net/favicon.ico", - "projectUrl": "http://www.sitecore.net/", - "licenseUrl": "http://www.sitecore.net/platform/pricing.aspx" - }, - "dependencies": { - "Sitecore.Commerce.Core": "1.0.2301", - "Sitecore.Commerce.Plugin.Coupons": "1.0.2301", - "Sitecore.Commerce.Plugin.Catalog.Cs": "1.0.2301", - "Sitecore.Commerce.Plugin.Inventory.Cs": "1.0.2301", - "Sitecore.Commerce.Plugin.Customers.Cs": "1.0.2301", - "Sitecore.Commerce.Plugin.Entitlements": "1.0.2301", - "Sitecore.Commerce.Plugin.GiftCards": "1.0.2301", - "Sitecore.Commerce.Plugin.Journaling": "1.0.2301", - "Sitecore.Commerce.Plugin.Management": "1.0.2301", - "Sitecore.Commerce.Plugin.Promotions": "1.0.2301", - "Sitecore.Commerce.Plugin.Returns": "1.0.2301", - "Sitecore.Commerce.Plugin.Shops": "1.0.2301", - "Sitecore.Commerce.Plugin.SQL": "1.0.2301", - "Sitecore.Commerce.Plugin.Tax": "1.0.2301", - "Sitecore.Commerce.Plugin.Views": "1.0.2301", - "Sitecore.Commerce.Plugin.Backorderable": "1.0.2301", - "Sitecore.Commerce.Plugin.Preorderable": "1.0.2301", - "Sitecore.Commerce.Plugin.Orders.DelayedAvailability": "1.0.2301", - "Plugin.Sample.Payments.Braintree": "1.0.2301" - }, - "frameworks": { - "net452": { - "frameworkAssemblies": { - "System.Transactions": "4.0.0.0" - } - } - }, - "configurations": { - "Release": { - "buildOptions": { - "compile": "../Shared/VersionInfo.cs", - "xmlDoc": true, - "warningsAsErrors": true, - "optimize": true - } - }, - "Demo-Retail": { - "buildOptions": { - "warningsAsErrors": true - } - }, - "Debug": { - "buildOptions": { - "warningsAsErrors": true - } - } - } -} diff --git a/src/Project/Retail/Engine.HabitatData/ConfigureSitecore.cs b/src/Project/Retail/Engine.HabitatData/ConfigureSitecore.cs new file mode 100644 index 00000000..fb61e20a --- /dev/null +++ b/src/Project/Retail/Engine.HabitatData/ConfigureSitecore.cs @@ -0,0 +1,32 @@ +using System.Reflection; + +using Microsoft.Extensions.DependencyInjection; + +using Sitecore.Commerce.Core; +using Sitecore.Framework.Configuration; +using Sitecore.Framework.Pipelines.Definitions.Extensions; +using Sitecore.Project.Commerce.Engine.Plugin.HabitatData.Pipelines.Blocks; + +namespace Sitecore.Project.Commerce.Engine.Plugin.HabitatData +{ + public class ConfigureSitecore : IConfigureSitecore + { + public void ConfigureServices(IServiceCollection services) + { + var assembly = Assembly.GetExecutingAssembly(); + services.RegisterAllPipelineBlocks(assembly); + services.RegisterAllCommands(assembly); + + services.Sitecore().Pipelines(config => config + + .ConfigurePipeline(c => + { + c.Add() + .Add() + .Add() + .Add(); + }) + ); + } + } +} diff --git a/src/Project/Retail/Engine.HabitatData/HabitatDataConstants.cs b/src/Project/Retail/Engine.HabitatData/HabitatDataConstants.cs new file mode 100644 index 00000000..19e6105a --- /dev/null +++ b/src/Project/Retail/Engine.HabitatData/HabitatDataConstants.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Sitecore.Project.Commerce.Engine.Plugin.HabitatData +{ + public class HabitatDataConstants + { + public static class Pipelines + { + public static class Blocks + { + public const string InitializeEnvironmentPricingBlock = "HabitatData.block.InitializeEnvironmentPricing"; + public const string InitializeEnvironmentPromotionsBlock = "HabitatData.block.InitializeEnvironmentPromotions"; + public const string InitializeEnvironmentGiftCardsBlock = "HabitatData.block.InitializeEnvironmentGiftCards"; + public const string InitializeEnvironmentSellableItemsBlock = "HabitatData.block.InitializeEnvironmentSellableItems"; + } + } + + public static class ArtifactSets + { + public const string Promotions = "Environment.Habitat.Promotions-1.0"; + public const string SellableItems = "Environment.Habitat.SellableItems-1.0"; + } + } +} diff --git a/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs new file mode 100644 index 00000000..6733a4db --- /dev/null +++ b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentGiftCardsBlock.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Availability; +using Sitecore.Commerce.Plugin.Catalog; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Commerce.Plugin.Pricing; +using Sitecore.Framework.Pipelines; + +namespace Sitecore.Project.Commerce.Engine.Plugin.HabitatData.Pipelines.Blocks +{ + [PipelineDisplayName(HabitatDataConstants.Pipelines.Blocks.InitializeEnvironmentGiftCardsBlock)] + public class InitializeEnvironmentGiftCardsBlock : PipelineBlock + { + private readonly IPersistEntityPipeline _persistEntityPipeline; + private readonly IFindEntityPipeline _findEntityPipeline; + + public InitializeEnvironmentGiftCardsBlock( + IPersistEntityPipeline persistEntityPipeline, IFindEntityPipeline findEntityPipeline) + { + this._persistEntityPipeline = persistEntityPipeline; + this._findEntityPipeline = findEntityPipeline; + } + + public override async Task Run(string arg, CommercePipelineExecutionContext context) + { + if (arg != "Habitat" && arg != "HabitatShops") + { + return arg; + } + + var itemId = $"{CommerceEntity.IdPrefix()}6042986"; + var findResult = await this._findEntityPipeline.Run(new FindEntityArgument(typeof(SellableItem), itemId, false), context.CommerceContext.GetPipelineContextOptions()); + + if (findResult == null) + { + var giftCard = new SellableItem + { + Id = itemId, + Name = "Default GiftCard", + Policies = new List + { + new AvailabilityAlwaysPolicy(), + new ListPricingPolicy(new List {new Money("USD", 0M), new Money("CAD", 0M)}) + }, + Components = new List + { + new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } }, + new ItemVariationsComponent + { + ChildComponents = new List + { + new ItemVariationComponent + { + Id = "56042986", + Name = "Gift Card", + Policies = new List + { + new AvailabilityAlwaysPolicy(), + new ListPricingPolicy(new List { new Money("USD", 25M), new Money("CAD", 26M) }) + } + }, + new ItemVariationComponent + { + Id = "56042987", + Name = "Gift Card", + Policies = new List + { + new AvailabilityAlwaysPolicy(), + new ListPricingPolicy(new List { new Money("USD", 50M), new Money("CAD", 51M) }) + } + }, + new ItemVariationComponent + { + Id = "56042988", + Name = "Gift Card", + Policies = new List + { + new AvailabilityAlwaysPolicy(), + new ListPricingPolicy(new List { new Money("USD", 100M), new Money("CAD", 101M) }) + } + } + } + } + } + }; + + await this._persistEntityPipeline.Run(new PersistEntityArgument(giftCard), context); + } + return arg; + } + } +} diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs similarity index 90% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs rename to src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs index 1502a583..d7bb19a9 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs +++ b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentPricingBlock.cs @@ -1,32 +1,17 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat +using Microsoft.Extensions.Logging; + +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Pricing; +using Sitecore.Framework.Pipelines; + +namespace Sitecore.Project.Commerce.Engine.Plugin.HabitatData.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Pricing; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which initializes pricing. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName("Habitat.InitializeEnvironmentPricingBlock")] + [PipelineDisplayName(HabitatDataConstants.Pipelines.Blocks.InitializeEnvironmentPricingBlock)] public class InitializeEnvironmentPricingBlock : PipelineBlock { private readonly IAddPriceBookPipeline _addPriceBookPipeline; @@ -36,15 +21,6 @@ public class InitializeEnvironmentPricingBlock : PipelineBlock - /// Initializes a new instance of the class. - /// - /// The add price book pipeline. - /// The add price card pipeline. - /// The add price snapshot pipeline. - /// The add price tier pipeline. - /// The add price snapshot tag pipeline. - /// The persist entity pipeline. public InitializeEnvironmentPricingBlock( IAddPriceBookPipeline addPriceBookPipeline, IAddPriceCardPipeline addPriceCardPipeline, @@ -61,18 +37,6 @@ public class InitializeEnvironmentPricingBlock : PipelineBlock - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(string arg, CommercePipelineExecutionContext context) { if (arg != "Habitat" && arg != "HabitatShops") diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs similarity index 95% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs rename to src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs index cdfa12d2..ada33205 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs +++ b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentPromotionsBlock.cs @@ -1,36 +1,20 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat +using Microsoft.Extensions.Logging; + +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Carts; +using Sitecore.Commerce.Plugin.Coupons; +using Sitecore.Commerce.Plugin.Fulfillment; +using Sitecore.Commerce.Plugin.Promotions; +using Sitecore.Commerce.Plugin.Rules; +using Sitecore.Framework.Pipelines; + +namespace Sitecore.Project.Commerce.Engine.Plugin.HabitatData.Pipelines.Blocks { - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; - - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Carts; - using Sitecore.Commerce.Plugin.Coupons; - using Sitecore.Commerce.Plugin.Fulfillment; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Commerce.Plugin.Promotions; - using Sitecore.Commerce.Plugin.Rules; - using Sitecore.Framework.Pipelines; - - /// - /// Defines a block which bootstraps promotions. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName("Habitat.InitializeEnvironmentPromotionsBlock")] + [PipelineDisplayName(HabitatDataConstants.Pipelines.Blocks.InitializeEnvironmentPromotionsBlock)] public class InitializeEnvironmentPromotionsBlock : PipelineBlock { private readonly IPersistEntityPipeline _persistEntityPipeline; @@ -42,17 +26,6 @@ public class InitializeEnvironmentPromotionsBlock : PipelineBlock - /// Initializes a new instance of the class. - /// - /// The persist entity pipeline. - /// The add book pipeline. - /// The add promotion pipeline. - /// The add qualification pipeline. - /// The add benefit pipeline. - /// The add private coupon pipeline. - /// The add promotion item pipeline. - /// The add public coupon pipeline. public InitializeEnvironmentPromotionsBlock( IPersistEntityPipeline persistEntityPipeline, IAddPromotionBookPipeline addBookPipeline, @@ -73,18 +46,6 @@ public class InitializeEnvironmentPromotionsBlock : PipelineBlock - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(string arg, CommercePipelineExecutionContext context) { if (arg != "Habitat" && arg != "HabitatShops") @@ -92,7 +53,7 @@ public override async Task Run(string arg, CommercePipelineExecutionCont return arg; } - var artifactSet = "Environment.Habitat.Promotions-1.0"; + var artifactSet = HabitatDataConstants.ArtifactSets.Promotions; // Check if this environment has subscribed to this Artifact Set if (!context.GetPolicy() diff --git a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs similarity index 55% rename from src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs rename to src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs index caee6a2c..95f04364 100644 --- a/src/Foundation/Commerce/legacyCommerce/Plugin.Sample.Habitat/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs +++ b/src/Project/Retail/Engine.HabitatData/Pipelines/Blocks/InitializeEnvironmentSellableItemsBlock.cs @@ -1,67 +1,31 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -// -------------------------------------------------------------------------------------------------------------------- +using System.Collections.Generic; +using System.Threading.Tasks; -namespace Plugin.Sample.Habitat -{ - using System.Collections.Generic; - using System.Threading.Tasks; - - using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; - using Sitecore.Commerce.Core; - using Sitecore.Commerce.Plugin.Availability; - using Sitecore.Commerce.Plugin.Catalog; - using Sitecore.Commerce.Plugin.ManagedLists; - using Sitecore.Framework.Pipelines; +using Sitecore.Commerce.Core; +using Sitecore.Commerce.Plugin.Availability; +using Sitecore.Commerce.Plugin.Catalog; +using Sitecore.Commerce.Plugin.ManagedLists; +using Sitecore.Framework.Pipelines; - /// - /// Defines a block which bootstraps sellable items the Habitat sample environment. - /// - /// - /// - /// Sitecore.Framework.Pipelines.PipelineBlock{System.String, System.String, - /// Sitecore.Commerce.Core.CommercePipelineExecutionContext} - /// - /// - [PipelineDisplayName(HabitatConstants.Pipelines.Blocks.BootstrapAwSellableItemsBlock)] +namespace Sitecore.Project.Commerce.Engine.Plugin.HabitatData.Pipelines.Blocks +{ + [PipelineDisplayName(HabitatDataConstants.Pipelines.Blocks.InitializeEnvironmentSellableItemsBlock)] public class InitializeEnvironmentSellableItemsBlock : PipelineBlock { private readonly IPersistEntityPipeline _persistEntityPipeline; private readonly IFindEntityPipeline _findEntityPipeline; - /// - /// Initializes a new instance of the class. - /// - /// - /// The persist entity pipeline. - /// - /// - /// The find entity pipeline. - /// public InitializeEnvironmentSellableItemsBlock(IPersistEntityPipeline persistEntityPipeline, IFindEntityPipeline findEntityPipeline) { this._persistEntityPipeline = persistEntityPipeline; this._findEntityPipeline = findEntityPipeline; } - /// - /// The run. - /// - /// - /// The argument. - /// - /// - /// The context. - /// - /// - /// The . - /// public override async Task Run(string arg, CommercePipelineExecutionContext context) { - var artifactSet = "Environment.Habitat.SellableItems-1.0"; + var artifactSet = HabitatDataConstants.ArtifactSets.SellableItems; // Check if this environment has subscribed to this Artifact Set if (!context.GetPolicy() @@ -84,13 +48,13 @@ public override async Task Run(string arg, CommercePipelineExecutionCont Id = itemId, Name = "Default Subscription", Policies = new List - { - new AvailabilityAlwaysPolicy() - }, + { + new AvailabilityAlwaysPolicy() + }, Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } } - } + { + new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } } + } }; await this._persistEntityPipeline.Run(new PersistEntityArgument(subscriptionSellableItem), context); } @@ -106,13 +70,13 @@ public override async Task Run(string arg, CommercePipelineExecutionCont Id = itemId, Name = "Default Installation", Policies = new List - { - new AvailabilityAlwaysPolicy() - }, + { + new AvailabilityAlwaysPolicy() + }, Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } } - } + { + new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } } + } }; await this._persistEntityPipeline.Run(new PersistEntityArgument(installationSellableItem), context); } @@ -128,13 +92,13 @@ public override async Task Run(string arg, CommercePipelineExecutionCont Id = itemId, Name = "Default Warranty", Policies = new List - { - new AvailabilityAlwaysPolicy() - }, + { + new AvailabilityAlwaysPolicy() + }, Components = new List - { - new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } } - } + { + new ListMembershipsComponent { Memberships = new List { CommerceEntity.ListName() } } + } }; await this._persistEntityPipeline.Run(new PersistEntityArgument(warrantySellableItem), context); } diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Properties/AssemblyInfo.cs b/src/Project/Retail/Engine.HabitatData/Properties/AssemblyInfo.cs similarity index 50% rename from src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Properties/AssemblyInfo.cs rename to src/Project/Retail/Engine.HabitatData/Properties/AssemblyInfo.cs index 8b1478c6..bbd598f8 100644 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Properties/AssemblyInfo.cs +++ b/src/Project/Retail/Engine.HabitatData/Properties/AssemblyInfo.cs @@ -1,21 +1,19 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) Sitecore Corporation 1999-2017 -// -//----------------------------------------------------------------------- - -using System; -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Sitecore.Commerce.Plugin.AdventureWorks")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Sitecore.Project.Commerce.Engine.Plugin.HabitatData")] +[assembly: AssemblyTrademark("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -[assembly: CLSCompliant(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b02c5772-df1e-48e5-b5ec-084ecf8a0b42")] diff --git a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Sitecore.Commerce.Plugin.AdventureWorks.xproj b/src/Project/Retail/Engine.HabitatData/Sitecore.Project.Commerce.Engine.Plugin.HabitatData.xproj similarity index 62% rename from src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Sitecore.Commerce.Plugin.AdventureWorks.xproj rename to src/Project/Retail/Engine.HabitatData/Sitecore.Project.Commerce.Engine.Plugin.HabitatData.xproj index a7f050ca..05eadbd7 100644 --- a/src/Foundation/Commerce/legacyCommerce/Sitecore.Commerce.Plugin.AdventureWorks/Sitecore.Commerce.Plugin.AdventureWorks.xproj +++ b/src/Project/Retail/Engine.HabitatData/Sitecore.Project.Commerce.Engine.Plugin.HabitatData.xproj @@ -6,19 +6,14 @@ - 45e1a5f7-861d-4929-a4c4-e3fd9d898f23 - Sitecore.Commerce.Plugin.AdventureWorks - ..\artifacts\obj\$(MSBuildProjectName) + b02c5772-df1e-48e5-b5ec-084ecf8a0b42 + Sitecore.Project.Commerce.Engine.Plugin.HabitatData + .\obj .\bin\ + v4.5.2 2.0 - - False - - - True - \ No newline at end of file diff --git a/src/Project/Retail/Engine.HabitatData/project.json b/src/Project/Retail/Engine.HabitatData/project.json new file mode 100644 index 00000000..970dc874 --- /dev/null +++ b/src/Project/Retail/Engine.HabitatData/project.json @@ -0,0 +1,19 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Sitecore.Commerce.Core": "1.0.2301", + "Sitecore.Commerce.Plugin.Availability": "1.0.2301", + "Sitecore.Commerce.Plugin.Catalog": "1.0.2301", + "Sitecore.Commerce.Plugin.Coupons": "1.0.2301", + "Sitecore.Commerce.Plugin.Fulfillment": "1.0.2301", + "Sitecore.Commerce.Plugin.ManagedLists": "1.0.2301", + "Sitecore.Commerce.Plugin.Pricing": "1.0.2301", + "Sitecore.Framework.Pipelines": "2.0.65" + }, + + "frameworks": { + "net452": { + } + } +}