Created
June 7, 2017 20:59
-
-
Save websterian/af66c37ae76269b861dbd08d839433cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Sitecore.Commerce.Connectors.MYERP.Plugin.Pipelines.Blocks | |
{ | |
using System; | |
using System.Threading.Tasks; | |
using Sitecore.Commerce.Connectors.MYERP.Plugin.Erp; | |
using Sitecore.Commerce.Core; | |
using Sitecore.Commerce.Plugin.Customers; | |
using Sitecore.Commerce.Plugin.Orders; | |
using Sitecore.Framework.Conditions; | |
using Sitecore.Framework.Pipelines; | |
/// <summary> | |
/// The process orders minion block. | |
/// </summary> | |
public class SendOrderToErpMinionBlock : PipelineBlock<Order, Order, CommercePipelineExecutionContext> | |
{ | |
/// <summary> | |
/// The _persistEntityPipeline. | |
/// </summary> | |
private readonly IPersistEntityPipeline _persistEntityPipeline; | |
/// <summary> | |
/// The _find entity pipeline. | |
/// </summary> | |
private readonly IFindEntityPipeline _findEntityPipeline; | |
/// <summary> | |
/// The service provider. | |
/// </summary> | |
private readonly IServiceProvider serviceProvider; | |
/// <summary> | |
/// The get customer pipeline. | |
/// </summary> | |
private readonly IGetCustomerPipeline getCustomerPipeline; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="SendOrderToErpMinionBlock"/> class. | |
/// </summary> | |
/// <param name="persistEntityPipeline"> | |
/// The persist entity pipeline. | |
/// </param> | |
/// <param name="findEntityPipeline"> | |
/// The find entity pipeline. | |
/// </param> | |
/// <param name="getCustomerPipeline"> | |
/// The get customer pipeline. | |
/// </param> | |
/// <param name="serviceProvider"> | |
/// The service provider. | |
/// </param> | |
public SendOrderToErpMinionBlock(IPersistEntityPipeline persistEntityPipeline, IFindEntityPipeline findEntityPipeline, IGetCustomerPipeline getCustomerPipeline, IServiceProvider serviceProvider) | |
{ | |
this._persistEntityPipeline = persistEntityPipeline; | |
this._findEntityPipeline = findEntityPipeline; | |
this.getCustomerPipeline = getCustomerPipeline; | |
this.serviceProvider = serviceProvider; | |
} | |
/// <summary> | |
/// The run. | |
/// </summary> | |
/// <param name="arg"> | |
/// The argument. | |
/// </param> | |
/// <param name="context"> | |
/// The context. | |
/// </param> | |
/// <returns> | |
/// The <see cref="Task"/>. | |
/// </returns> | |
public override async Task<Order> Run(Order arg, CommercePipelineExecutionContext context) | |
{ | |
Condition.Requires(arg).IsNotNull("The argument can not be null"); | |
var integrationHelper = new IntegrationHelper(this._persistEntityPipeline, this._findEntityPipeline, this.serviceProvider, this.getCustomerPipeline); | |
var returnedOrder = await integrationHelper.TranslateOrderAndSendToErp(arg, context); | |
return returnedOrder; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment