public PipelineExecutionResult Execute(IPipelineArgs <AddAddressRequest, AddAddressResult> subject)
        {
            if (subject.Request.Properties.ContainsKey("FromUCommerce"))
            {
                if (!(bool)subject.Request.Properties["FromUCommerce"])
                {
                    return(PipelineExecutionResult.Success);
                }
            }

            var cartServiceProvider = new CartServiceProvider();
            var cart = _mappingLibraryInternal.MapPurchaseOrderToCart(subject.Request.PurchaseOrder);

            var party     = _orderAddressMapper.Map(subject.Response.OrderAddress);
            var partyList = new List <Party> {
                party
            };

            if (subject.Request.ExistingOrderAddress == null)
            {
                var addPartiesRequest = new AddPartiesRequest(cart, partyList);
                addPartiesRequest.Properties["FromUCommerce"] = true;
                var addPartiesResult = cartServiceProvider.AddParties(addPartiesRequest);

                return(PipelineExecutionResult.Success);
            }

            var updatePartiesRequest = new UpdatePartiesRequest(cart, partyList);

            updatePartiesRequest.Properties["FromUCommerce"] = true;
            var updatePartiesResult = cartServiceProvider.UpdateParties(updatePartiesRequest);

            return(PipelineExecutionResult.Success);
        }
Beispiel #2
0
        private void EditBillingInformation(AddressSaveViewModel.Address billingAddress)
        {
            var cartServiceProvider = new CartServiceProvider();
            var cart  = GetCart();
            var party = new Party()
            {
                Address1      = billingAddress.Line1,
                Address2      = billingAddress.Line2,
                City          = billingAddress.City,
                Company       = billingAddress.CompanyName,
                Country       = _countries.Select().First(x => x.CountryId == billingAddress.CountryId).Name,
                Email         = billingAddress.EmailAddress,
                FirstName     = billingAddress.FirstName,
                LastName      = billingAddress.LastName,
                PartyId       = "Billing",
                PhoneNumber   = billingAddress.PhoneNumber,
                State         = billingAddress.State,
                ZipPostalCode = billingAddress.PostalCode
            };
            var partyList = new List <Party> {
                party
            };

            if (cart.Parties.Any(x => x.PartyId == party.PartyId))
            {
                var updatePartiesRequest = new UpdatePartiesRequest(cart, partyList);
                var updatePartiesResult  = cartServiceProvider.UpdateParties(updatePartiesRequest);

                return;
            }

            var addPartiesRequest = new AddPartiesRequest(cart, partyList);
            var addPartiesResult  = cartServiceProvider.AddParties(addPartiesRequest);
        }