public override async Task <Order> Run(Order order, CommercePipelineExecutionContext context) { Condition.Requires(order).IsNotNull($"{Name}: The argument can not be null"); var serviceBusOrderPlacedPolicy = context.GetPolicy <ServiceBusOrderPlacedPolicy>(); if (!serviceBusOrderPlacedPolicy.Enabled) { context.Logger.LogInformation("Feature.Order.ServiceBus: Plugin is disabled - Order not added to Complete list"); return(order); } try { await _addListEntitiesPipeline.Run(new ListEntitiesArgument(new[] { order.Id }, serviceBusOrderPlacedPolicy.OrderSentListName), context); } catch (Exception ex) { context.Logger.LogError($"Feature.Order.ServiceBus: {ex.Message} {ex.StackTrace}"); } await _eventRegistry.ListItemUpdated().Send(order, Name); return(order); }
public override async Task <ProductComparison> Run(AddToProductCompareArgument arg, CommercePipelineExecutionContext context) { Contract.Requires(arg != null); Contract.Requires(context != null); Condition.Requires(arg).IsNotNull($"{Name}: The arg can not be null"); Condition.Requires(arg.ProductId).IsNotNull($"{Name}: The product id can not be null"); Condition.Requires(arg.CompareCollection).IsNotNull($"{Name}: The Compare Collection can not be null"); var sellableItem = await _getSellableItemPipeline.Run(BuildProductArgument(arg), context).ConfigureAwait(false); if (sellableItem == null) { context.Logger.LogWarning($"ProductCompare: Unable to find sellable item to add to collection:{arg.CatalogName}-{arg.ProductId}-{arg.VariantId}"); return(arg.CompareCollection); } var list = arg.CompareCollection.Products.ToList(); if (list.Any(x => x.Id == sellableItem.Id)) { context.Logger.LogDebug($"{Name}: SellableItem already exists in compare collection, no further action to take"); return(arg.CompareCollection); } var addArg = new ListEntitiesArgument(new List <string> { sellableItem.Id }, arg.CompareCollection.Name); await _addListEntitiesPipeline.Run(addArg, context).ConfigureAwait(false); return(arg.CompareCollection); }
public override async Task <CatalogContentArgument> Run(SynchronizeCatalogArgument arg, CommercePipelineExecutionContext context) { var ids = arg.MasterProducts.Select(p => $"{arg.CatalogId}_{p.Id.ToString()}"); var addArg = new ListEntitiesArgument(ids, "ProductUpdatesList"); await _addListEntitiesPipeline.Run(addArg, context); return(arg); }