/// <summary> /// The execute. /// </summary> /// <param name="arg"> /// The pipeline argument. /// </param> /// <param name="context"> /// The context. /// </param> /// <returns> /// The <see cref="PipelineArgument"/>. /// </returns> public override async Task <EntityView> Run(EntityView arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The argument can not be null"); var cartViewsPolicy = context.GetPolicy <KnownCartViewsPolicy>(); if (!arg.Name.Equals(cartViewsPolicy.CartsDashboard, StringComparison.InvariantCultureIgnoreCase)) { return(arg); } EntityViewArgument entityViewArgument = context.CommerceContext.GetObjects <EntityViewArgument>().FirstOrDefault <EntityViewArgument>(); var cartsView = new EntityView() { Name = "Carts", DisplayName = "Carts", UiHint = "Table" }; arg.ChildViews.Add(cartsView); string listName = "Carts"; await this.SetListMetadata(cartsView, listName, "PaginateCartsViewList", context); var carts = (await this.GetEntities(arg, "Carts", context)).OfType <Cart>(); cartsView.FillWithCarts(carts); return(arg); }
/// <summary> /// The execute. /// </summary> /// <param name="arg"> /// The pipeline argument. /// </param> /// <param name="context"> /// The context. /// </param> /// <returns> /// The <see cref="PipelineArgument"/>. /// </returns> public override async Task <EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context) { Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument can not be null"); if (string.IsNullOrEmpty(entityView.Name) || !entityView.Name.Contains("Carts") || !this.Validate(entityView, context.CommerceContext)) { return(entityView); } var cartsForPage = (await this.GetEntities(entityView, context)).OfType <Cart>(); entityView.FillWithCarts(cartsForPage); return(entityView); }