예제 #1
0
        protected virtual CustomerParty GetBuyerCustomerParty(ActiveCommerce.Orders.Legacy.Order source)
        {
            Assert.ArgumentNotNull(source, "source");
            Assert.IsNotNull(source.CustomerInfo, "customerinfo");

            var customerParty = OrderFactory.CreateCustomerParty();
            var party         = OrderFactory.CreateParty();
            var contact       = OrderFactory.CreateContact();

            var list = new List <Sitecore.Ecommerce.Common.Communication>();

            if (!string.IsNullOrEmpty(source.CustomerInfo.Email2))
            {
                var communication = OrderFactory.CreateCommunication();
                communication.Channel = source.CustomerInfo.Email2;
                communication.Value   = source.CustomerInfo.Email2;
                communication.Contact = contact;
                list.Add(communication);
            }
            if (!string.IsNullOrEmpty(source.CustomerInfo.Mobile))
            {
                var communication = OrderFactory.CreateCommunication();
                communication.Channel = source.CustomerInfo.Mobile;
                communication.Value   = source.CustomerInfo.Mobile;
                communication.Contact = contact;
                list.Add(communication);
            }
            if (list.Any())
            {
                contact.OtherCommunications = list;
            }

            contact.Name           = GetFullName(source.CustomerInfo.BillingAddress);
            contact.ElectronicMail = source.CustomerInfo.Email;
            contact.Telefax        = source.CustomerInfo.Fax;
            contact.Telephone      = source.CustomerInfo.Phone;
            contact.ID             = source.CustomerInfo.CustomerId;
            var nickName = Sitecore.Context.Domain.GetShortName(source.CustomerInfo.NickName);

            if (!string.IsNullOrEmpty(nickName) && nickName != Sitecore.Constants.AnonymousUserName)
            {
                contact.UserName = source.CustomerInfo.NickName;
            }

            party.Contact       = contact;
            party.PostalAddress = GetAddress(source.CustomerInfo.BillingAddress);
            party.PartyName     = GetFullName(source.CustomerInfo.BillingAddress);
            party.LanguageCode  = Sitecore.Context.Language.Name;
            party.Person        = GetPerson(source.CustomerInfo.BillingAddress);

            customerParty.Party = party;
            customerParty.SupplierAssignedAccountID = source.CustomerInfo.CustomerId;

            return(customerParty);
        }