Example #1
0
        /// <summary>
        /// Adds the party.
        /// </summary>
        /// <param name="party">The party.</param>
        /// <param name="entityName">Name of the entity.</param>
        /// <param name="cartContext">The cart context.</param>
        /// <returns>
        /// The commerce party that was added.
        /// </returns>
        protected virtual ConnectOrderModels.CommerceParty AddParty(Party party, string entityName, CartPipelineContext cartContext)
        {
            OrderAddress destinationAddress = CommerceTypeLoader.CreateInstance <OrderAddress>(new object[] { this.GetPartyName(party), party.ExternalId });

            RefSFArguments.TranslateEntityToOrderAddressRequest translateRequest = new RefSFArguments.TranslateEntityToOrderAddressRequest(party, destinationAddress);

            var translateResult = PipelineUtility.RunCommerceConnectPipeline <RefSFArguments.TranslateEntityToOrderAddressRequest, TranslateEntityToOrderAddressResult>(PipelineNames.TranslateEntityToOrderAddress, translateRequest);

            OrderAddress newOrderAddress = translateResult.Address;

            cartContext.Basket.Addresses.Add(newOrderAddress);

            ConnectOrderModels.CommerceParty translatedParty = this.EntityFactory.Create <ConnectOrderModels.CommerceParty>(entityName);
            Assert.ArgumentNotNull(translatedParty, "translatedParty");

            RefSFArguments.TranslateOrderAddressToEntityRequest translateOrderAddressRequest = new RefSFArguments.TranslateOrderAddressToEntityRequest(newOrderAddress, translatedParty);
            PipelineUtility.RunCommerceConnectPipeline <RefSFArguments.TranslateOrderAddressToEntityRequest, CommerceResult>(PipelineNames.TranslateOrderAddressToEntity, translateOrderAddressRequest);

            return(translatedParty);
        }
Example #2
0
        /// <summary>
        /// Translates the specified source party.
        /// </summary>
        /// <param name="sourceParty">The source party.</param>
        /// <param name="destinationAddress">The destination address.</param>
        protected virtual void TranslateCommerceParty([NotNull] ConnectOrderModels.CommerceParty sourceParty, [NotNull] OrderAddress destinationAddress)
        {
            Assert.ArgumentNotNullOrEmpty(sourceParty.Name, "sourceParty.Name");

            destinationAddress.City               = sourceParty.City;
            destinationAddress.CountryName        = sourceParty.Country;
            destinationAddress.DaytimePhoneNumber = sourceParty.PhoneNumber;
            destinationAddress.Email              = sourceParty.Email;
            destinationAddress.FirstName          = sourceParty.FirstName;
            destinationAddress.LastName           = sourceParty.LastName;
            destinationAddress.Line1              = sourceParty.Address1;
            destinationAddress.Line2              = sourceParty.Address2;
            destinationAddress.PostalCode         = sourceParty.ZipPostalCode;
            destinationAddress.State              = sourceParty.State;
            destinationAddress.CountryCode        = sourceParty.CountryCode;
            destinationAddress.EveningPhoneNumber = sourceParty.EveningPhoneNumber;
            destinationAddress.FaxNumber          = sourceParty.FaxNumber;
            destinationAddress.Name               = sourceParty.Name;
            destinationAddress.Organization       = sourceParty.Company;
            destinationAddress.RegionCode         = sourceParty.RegionCode;
            destinationAddress.RegionName         = sourceParty.RegionName;

            this.TranslateCommercePartyCustomProperties(sourceParty, destinationAddress);
        }
Example #3
0
        /// <summary>
        /// Adds the user profile address.
        /// </summary>
        /// <param name="party">The party.</param>
        /// <param name="cartContext">The cart context.</param>
        /// <returns>The commerce party that was added.</returns>
        protected virtual ConnectOrderModels.CommerceParty AddUserProfileAddress(ConnectOrderModels.CommerceParty party, CartPipelineContext cartContext)
        {
            Assert.IsTrue(party.UserProfileAddressId != Guid.Empty, "party.UserProfileAddressId != Guid.Empty");
            Assert.IsNotNullOrEmpty(party.Name, "party.Name");

            var repository = this.GetProfileRepository();

            Profile addressProfile = repository.GetProfile("Address", party.UserProfileAddressId.ToString("B"));

            Assert.IsNotNull(addressProfile, string.Format(CultureInfo.InvariantCulture, "An invalid address profile was provided: {0}", party.UserProfileAddressId.ToString("B")));

            OrderAddress newOrderAddress = CommerceTypeLoader.CreateInstance <OrderAddress>(new object[] { party.Name, addressProfile });

            cartContext.Basket.Addresses.Add(newOrderAddress);

            ConnectOrderModels.CommerceParty translatedParty = this.EntityFactory.Create <ConnectOrderModels.CommerceParty>("Party");
            Assert.ArgumentNotNull(translatedParty, "translatedParty");

            var translateOrderAddressRequest = new RefSFArguments.TranslateOrderAddressToEntityRequest(newOrderAddress, translatedParty);

            PipelineUtility.RunCommerceConnectPipeline <RefSFArguments.TranslateOrderAddressToEntityRequest, CommerceResult>(PipelineNames.TranslateOrderAddressToEntity, translateOrderAddressRequest);

            return(translatedParty);
        }
 /// <summary>
 /// Translates to custom address properties.
 /// </summary>
 /// <param name="sourceAddress">The source address.</param>
 /// <param name="destinationParty">The destination party.</param>
 protected virtual void TranslateToCustomAddressProperties([NotNull] CommerceServer.Core.Runtime.Orders.OrderAddress sourceAddress, [NotNull] ConnectOrderModels.CommerceParty destinationParty)
 {
 }
        /// <summary>
        /// Translates to commerce party.
        /// </summary>
        /// <param name="sourceAddress">The source address.</param>
        /// <param name="destinationParty">The destination party.</param>
        protected virtual void TranslateToCommerceParty(CommerceServer.Core.Runtime.Orders.OrderAddress sourceAddress, ConnectOrderModels.CommerceParty destinationParty)
        {
            destinationParty.ExternalId         = sourceAddress.OrderAddressId;
            destinationParty.City               = sourceAddress.City;
            destinationParty.Country            = sourceAddress.CountryName;
            destinationParty.CountryCode        = sourceAddress.CountryCode;
            destinationParty.PhoneNumber        = sourceAddress.DaytimePhoneNumber;
            destinationParty.Email              = sourceAddress.Email;
            destinationParty.FirstName          = sourceAddress.FirstName;
            destinationParty.LastName           = sourceAddress.LastName;
            destinationParty.Address1           = sourceAddress.Line1;
            destinationParty.Address2           = sourceAddress.Line2;
            destinationParty.ZipPostalCode      = sourceAddress.PostalCode;
            destinationParty.State              = sourceAddress.State;
            destinationParty.EveningPhoneNumber = sourceAddress.EveningPhoneNumber;
            destinationParty.FaxNumber          = sourceAddress.FaxNumber;
            destinationParty.Name               = sourceAddress.Name;
            destinationParty.Company            = sourceAddress.Organization;
            destinationParty.RegionCode         = sourceAddress.RegionCode;
            destinationParty.RegionName         = sourceAddress.RegionName;

            this.TranslateToCustomAddressProperties(sourceAddress, destinationParty);
        }
Example #6
0
 /// <summary>
 /// Translates the custom properties.
 /// </summary>
 /// <param name="sourceParty">The source party.</param>
 /// <param name="destinationAddress">The destination address.</param>
 protected virtual void TranslateCommercePartyCustomProperties([NotNull] ConnectOrderModels.CommerceParty sourceParty, [NotNull] OrderAddress destinationAddress)
 {
     destinationAddress[CommerceServerStorefrontConstants.KnowWeaklyTypesProperties.PartyType] = 1;
 }