Пример #1
0
        private void AddContactData(PublicOrder order, ContactModel billingContact)
        {
            order.BillingEmail = Normalize(billingContact.Email);

            order.BillingFirstName = Normalize(billingContact.FirstName);
            order.BillingLastName  = Normalize(billingContact.LastName);

            order.BillingAddress  = Normalize(billingContact.Address);
            order.BillingAddress2 = Normalize(billingContact.Address2);
            order.BillingZip      = Normalize(billingContact.Zip);
            order.BillingCity     = Normalize(billingContact.City);
            order.BillingCountry  = Normalize(billingContact.Country);

            var fax = FormattingHelper.FormatPhoneNumber(billingContact.Fax, billingContact.Country);

            order.BillingFax = Normalize(fax);

            var phone = FormattingHelper.FormatPhoneNumber(billingContact.Phone, billingContact.Country);

            order.BillingPhone = Normalize(phone);

            if (billingContact.CustomerType == "individual" && billingContact.IndividualInfo != null)
            {
                order.BillingCompanyNumber = Normalize(billingContact.IndividualInfo.IdentityNumber);
            }
            else if (billingContact.CustomerType == "company" && billingContact.CompanyInfo != null)
            {
                order.BillingCompany       = Normalize(billingContact.CompanyInfo.CompanyName);
                order.BillingCompanyNumber = Normalize(billingContact.CompanyInfo.IdentityNumber);
            }
        }
Пример #2
0
        /// <summary>
        /// Amend order with main contact data collected from customer.
        /// </summary>
        public override PublicOrder AmendOrder(PublicOrder order, PublicOrderContext orderContext)
        {
            var mainContact = orderContext.ContactData.OfType <MainContactModel>().First();

            order.Email = Normalize(mainContact.Email);

            order.FirstName = Normalize(mainContact.FirstName);
            order.LastName  = Normalize(mainContact.LastName);

            order.Address  = Normalize(mainContact.Address);
            order.Address2 = Normalize(mainContact.Address2);
            order.Zip      = Normalize(mainContact.Zip);
            order.City     = Normalize(mainContact.City);
            order.Country  = Normalize(mainContact.Country);

            var fax = FormattingHelper.FormatPhoneNumber(mainContact.Fax, mainContact.Country);

            order.Fax = Normalize(fax);

            var phone = FormattingHelper.FormatPhoneNumber(mainContact.Phone, mainContact.Country);

            order.Phone = Normalize(phone);

            if (mainContact.CustomerType == "individual" && mainContact.IndividualInfo != null)
            {
                order.CompanyNumber = Normalize(mainContact.IndividualInfo.IdentityNumber);
            }
            else if (mainContact.CustomerType == "company" && mainContact.CompanyInfo != null)
            {
                order.Company       = Normalize(mainContact.CompanyInfo.CompanyName);
                order.CompanyNumber = Normalize(mainContact.CompanyInfo.IdentityNumber);
                order.LegalNumber   = Normalize(mainContact.CompanyInfo.VatNumber);
            }

            if (AtomiaCommon.Instance.SeparateUsernameAndEmail)
            {
                var customAttributes = new List <PublicOrderCustomData>(order.CustomData);
                customAttributes.Add(new PublicOrderCustomData {
                    Name = "Username", Value = Normalize(mainContact.Username)
                });
                order.CustomData = customAttributes.ToArray();
            }

            return(order);
        }
        public DomainRegContactProvider(PublicOrderContext orderContext)
        {
            if (orderContext == null)
            {
                throw new ArgumentNullException("orderContext");
            }

            var whoisContact = orderContext.ContactData.OfType <WhoisContactModel>().FirstOrDefault();
            var mainContact  = orderContext.ContactData.OfType <MainContactModel>().FirstOrDefault();

            // No separate WHOIS contact added by customer.
            if ((whoisContact == null || String.IsNullOrEmpty(whoisContact.Email))
                &&
                (mainContact == null || mainContact.CustomFieldsInfo == null ||
                 mainContact.CustomFieldsInfo.CustomFieldsDict == null ||
                 mainContact.CustomFieldsInfo.CustomFieldsDict.Count == 0))
            {
                _domainRegContactData = "";
            }
            else
            {
                if (whoisContact == null || String.IsNullOrEmpty(whoisContact.Email))
                {
                    //whoisContact not filled out but there are custom fields in mainContact. Copy rest of the properties.
                    whoisContact              = whoisContact ?? new WhoisContactModel();
                    whoisContact.Address      = mainContact.Address;
                    whoisContact.Address2     = mainContact.Address2;
                    whoisContact.CartItems    = mainContact.CartItems;
                    whoisContact.City         = mainContact.City;
                    whoisContact.Country      = mainContact.Country;
                    whoisContact.CustomerType = mainContact.CustomerType;
                    whoisContact.Email        = mainContact.Email;
                    whoisContact.Fax          = mainContact.Fax;
                    whoisContact.FirstName    = mainContact.FirstName;
                    whoisContact.LastName     = mainContact.LastName;
                    whoisContact.Phone        = mainContact.Phone;
                    whoisContact.ResellerId   = mainContact.ResellerId;
                    whoisContact.State        = mainContact.State;
                    whoisContact.Zip          = mainContact.Zip;
                    whoisContact.IndividualInfo.IdentityNumber = mainContact.IndividualInfo.IdentityNumber;
                    whoisContact.CompanyInfo.CompanyName       = mainContact.CompanyInfo.CompanyName;
                    whoisContact.CompanyInfo.IdentityNumber    = mainContact.CompanyInfo.IdentityNumber;
                    whoisContact.CompanyInfo.VatNumber         = mainContact.CompanyInfo.VatNumber;
                }

                if (mainContact != null && mainContact.CustomFieldsInfo != null &&
                    mainContact.CustomFieldsInfo.CustomFieldsDict != null &&
                    mainContact.CustomFieldsInfo.CustomFieldsDict.Count > 0)
                {
                    whoisContact.CustomFieldsInfo.CustomFieldsDict = mainContact.CustomFieldsInfo.CustomFieldsDict;
                }
                var phone = FormattingHelper.FormatPhoneNumber(whoisContact.Phone, whoisContact.Country);
                var fax   = FormattingHelper.FormatPhoneNumber(whoisContact.Fax, whoisContact.Country);

                string org   = "";
                string orgNo = "";
                string vatNo = "";

                if (whoisContact.CompanyInfo != null && !string.IsNullOrEmpty(whoisContact.CompanyInfo.CompanyName))
                {
                    org   = whoisContact.CompanyInfo.CompanyName;
                    orgNo = whoisContact.CompanyInfo.IdentityNumber;
                    vatNo = whoisContact.CompanyInfo.VatNumber;
                }
                else
                {
                    orgNo = whoisContact.IndividualInfo.IdentityNumber;
                }

                var domainRegContact = new DomainRegContact
                {
                    City    = OrderDataHandler.NormalizeData(whoisContact.City),
                    Country = OrderDataHandler.NormalizeData(whoisContact.Country),
                    Email   = OrderDataHandler.NormalizeData(whoisContact.Email),
                    Fax     = OrderDataHandler.NormalizeData(fax),
                    Name    =
                        OrderDataHandler.NormalizeData(whoisContact.FirstName) + " " +
                        OrderDataHandler.NormalizeData(whoisContact.LastName),
                    Org              = OrderDataHandler.NormalizeData(org),
                    OrgNo            = OrderDataHandler.NormalizeData(orgNo),
                    Street1          = OrderDataHandler.NormalizeData(whoisContact.Address),
                    Street2          = OrderDataHandler.NormalizeData(whoisContact.Address2),
                    VatNo            = OrderDataHandler.NormalizeData(vatNo),
                    Voice            = OrderDataHandler.NormalizeData(phone),
                    Zip              = OrderDataHandler.NormalizeData(whoisContact.Zip),
                    CustomFields     = new JavaScriptSerializer().Serialize(whoisContact.CustomFieldsInfo.CustomFieldsDict),
                    CustomFieldsDict = whoisContact.CustomFieldsInfo.CustomFieldsDict
                };

                _domainRegContactData = new JavaScriptSerializer().Serialize(domainRegContact);
            }
        }