public PipelineExecutionResult Execute(IPipelineArgs <RemoveShipmentRequest, RemoveShipmentResult> subject) { if (subject.Request.Properties.ContainsKey("FromUCommerce")) { if (!(bool)subject.Request.Properties["FromUCommerce"]) { return(PipelineExecutionResult.Success); } } var cart = MappingLibrary.MapPurchaseOrderToCart(subject.Request.PurchaseOrder); var cartService = new CartServiceProvider(); var shippingList = new List <ShippingInfo> { new ShippingInfo() { ExternalId = subject.Request.Shipment.ShipmentId.ToString(), PartyID = subject.Request.Shipment.ShipmentAddress.OrderAddressId.ToString(), ShippingMethodID = subject.Request.Shipment.ShippingMethod.ShippingMethodId.ToString() } }; var request = new RemoveShippingInfoRequest(cart, shippingList); request.Properties["FromUCommerce"] = true; var result = cartService.RemoveShippingInfo(request); return(PipelineExecutionResult.Success); }
public ActionResult CreateShipment(ShippingPickerViewModel createShipmentViewModel) { var cartService = new CartServiceProvider(); var cart = GetCart(); if (cart.Shipping.Any()) { var removeRequest = new RemoveShippingInfoRequest(cart, cart.Shipping.ToList()); var removeResult = cartService.RemoveShippingInfo(removeRequest); } var shippingParty = cart.Parties.FirstOrDefault(x => x.PartyId == Constants.DefaultShipmentAddressName); var shippingList = new List <ShippingInfo> { new ShippingInfo() { ShippingMethodID = createShipmentViewModel.SelectedShippingMethodId.ToString(), PartyID = shippingParty.PartyId } }; var addRequest = new AddShippingInfoRequest(cart, shippingList); var addResult = cartService.AddShippingInfo(addRequest); return(Redirect("/payment")); }