/// <summary>
        /// Translates the commerce customer party.
        /// </summary>
        /// <param name="party">The party.</param>
        /// <param name="profile">The profile.</param>
        protected virtual void TranslateCommerceCustomerParty(RefSFModels.CommerceParty party, CommerceServer.Core.Runtime.Profiles.Profile profile)
        {
            profile["GeneralInfo.first_name"].Value = party.FirstName;
            profile["GeneralInfo.last_name"].Value = party.LastName;
            profile["GeneralInfo.address_name"].Value = party.Name;
            profile["GeneralInfo.address_line1"].Value = party.Address1;
            profile["GeneralInfo.address_line2"].Value = party.Address2;
            profile["GeneralInfo.city"].Value = party.City;
            profile["GeneralInfo.region_code"].Value = party.RegionCode;
            profile["GeneralInfo.region_name"].Value = party.RegionName;
            profile["GeneralInfo.postal_code"].Value = party.ZipPostalCode;
            profile["GeneralInfo.country_code"].Value = party.CountryCode;
            profile["GeneralInfo.country_name"].Value = party.Country;
            profile["GeneralInfo.tel_number"].Value = party.PhoneNumber;
            profile["GeneralInfo.region_code"].Value = party.State;

            this.TranslateCommerceCustomerPartyCustomProperties(party, profile);
        }
 /// <summary>
 /// Translates the custom party.
 /// </summary>
 /// <param name="party">The party.</param>
 /// <param name="profile">The profile.</param>
 private void TranslateCustomParty(RefSFModels.CommerceParty party, CommerceServer.Core.Runtime.Profiles.Profile profile)
 {
 }
 /// <summary>
 /// Translates the commerce customer party custom properties.
 /// </summary>
 /// <param name="party">The party.</param>
 /// <param name="profile">The profile.</param>
 protected virtual void TranslateCommerceCustomerPartyCustomProperties(RefSFModels.CommerceParty party, CommerceServer.Core.Runtime.Profiles.Profile profile)
 {
 }
 /// <summary>
 /// Translates the address.
 /// </summary>
 /// <param name="sourceAddress">The source address.</param>
 /// <param name="destinationParty">The destination party.</param>
 protected virtual void TranslateAddress(CommerceServer.Core.Runtime.Orders.OrderAddress sourceAddress, RefSFModels.EmailParty destinationParty)
 {
     RefSFArguments.TranslateOrderAddressToEntityRequest request = new RefSFArguments.TranslateOrderAddressToEntityRequest(sourceAddress, destinationParty);
     PipelineUtility.RunCommerceConnectPipeline<RefSFArguments.TranslateOrderAddressToEntityRequest, CommerceResult>(PipelineNames.TranslateOrderAddressToEntity, request);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Processes the commerce party.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="customerProfile">The customer profile.</param>
        /// <param name="partyToAdd">The party to add.</param>
        /// <returns>Newly created party.</returns>
        protected virtual Party ProcessCommerceParty(AddPartiesResult result, Profile customerProfile, RefSFModels.CommerceParty partyToAdd)
        {
            Assert.ArgumentNotNull(partyToAdd.Name, "partyToAdd.Name");
            Assert.ArgumentNotNull(partyToAdd.ExternalId, "partyToAdd.ExternalId");

            Profile addressProfile = null;
            var response = this.CreateAddressProfile(partyToAdd.ExternalId, ref addressProfile);
            if (!response.Success)
            {
                result.Success = false;
                response.SystemMessages.ToList().ForEach(m => result.SystemMessages.Add(m));
                return null;
            }

            var requestToCommerceProfile = new TranslateEntityToCommerceAddressProfileRequest(partyToAdd, addressProfile);
            PipelineUtility.RunCommerceConnectPipeline<TranslateEntityToCommerceAddressProfileRequest, CommerceResult>(CommerceServerStorefrontConstants.PipelineNames.TranslateEntityToCommerceAddressProfile, requestToCommerceProfile);

            addressProfile.Update();

            ProfilePropertyListCollection<string> addressList;
            var profileValue = customerProfile["GeneralInfo.address_list"].Value as object[];
            if (profileValue != null)
            {
                var e = profileValue.Select(i => i.ToString());
                addressList = new ProfilePropertyListCollection<string>(e);
            }
            else
            {
                addressList = new ProfilePropertyListCollection<string>();
            }

            addressList.Add(partyToAdd.ExternalId);
            customerProfile["GeneralInfo.address_list"].Value = addressList.Cast<object>().ToArray();

            if (partyToAdd.IsPrimary)
            {
                customerProfile["GeneralInfo.preferred_address"].Value = partyToAdd.ExternalId;
            }

            customerProfile.Update();

            var newParty = this.EntityFactory.Create<RefSFModels.CommerceParty>("Party");
            TranslateCommerceAddressProfileToEntityRequest requestToEntity = new TranslateCommerceAddressProfileToEntityRequest(addressProfile, newParty);
            PipelineUtility.RunCommerceConnectPipeline<TranslateCommerceAddressProfileToEntityRequest, CommerceResult>(CommerceServerStorefrontConstants.PipelineNames.TranslateCommerceAddressProfileToEntity, requestToEntity);

            return requestToEntity.DestinationParty;
        }