Exemplo n.º 1
0
        public string ValidateNlIdentity(CreateOrderBuilder order)
        {
            string errors = "";

            //Individual
            if (!order.GetIsCompanyIdentity())
            {
                if (order.GetIndividualCustomer().GetInitials() == null)
                {
                    errors +=
                        "MISSING VALUE - Initials is required for individual customers when countrycode is NL. Use SetInitials().\n";
                }
                if (order.GetIndividualCustomer().GetBirthDate() == null)
                {
                    errors +=
                        "MISSING VALUE - Birth date is required for individual customers when countrycode is NL. Use SetBirthDate().\n";
                }
                if (order.GetIndividualCustomer().GetFirstName() == null ||
                    order.GetIndividualCustomer().GetLastName() == null)
                {
                    errors +=
                        "MISSING VALUE - Name is required for individual customers when countrycode is NL. Use SetName().\n";
                }
            }

            //Company
            if (order.GetIsCompanyIdentity())
            {
                if (order.GetCompanyCustomer().GetVatNumber() == null)
                {
                    errors +=
                        "MISSING VALUE - Vat number is required for company customers when countrycode is NL. Use SetVatNumber().\n";
                }
                if (order.GetCompanyCustomer().GetCompanyName() == null)
                {
                    errors +=
                        "MISSING VALUE - Company name is required for individual customers when countrycode is NL. Use SetName().\n";
                }
            }

            //Individual and Company
            if (order.GetCustomerIdentity().Street == null || order.GetCustomerIdentity().HouseNumber == null)
            {
                errors +=
                    "MISSING VALUE - Street address and house number is required for all customers when countrycode is NL. Use SetStreetAddress().\n";
            }
            if (order.GetCustomerIdentity().Locality == null)
            {
                errors +=
                    "MISSING VALUE - Locality is required for all customers when countrycode is NL. Use SetLocality().\n";
            }
            if (order.GetCustomerIdentity().ZipCode == null)
            {
                errors +=
                    "MISSING VALUE - Zip code is required for all customers when countrycode is NL. Use SetZipCode().\n";
            }

            return(errors);
        }
        public string ValidateNlIdentity(CreateOrderBuilder order)
        {
            string errors = "";
            //Individual
            if (!order.GetIsCompanyIdentity())
            {
                if (order.GetIndividualCustomer().GetInitials() == null)
                {
                    errors +=
                        "MISSING VALUE - Initials is required for individual customers when countrycode is NL. Use SetInitials().\n";
                }
                if (order.GetIndividualCustomer().GetBirthDate() == null)
                {
                    errors +=
                        "MISSING VALUE - Birth date is required for individual customers when countrycode is NL. Use SetBirthDate().\n";
                }
                if (order.GetIndividualCustomer().GetFirstName() == null ||
                    order.GetIndividualCustomer().GetLastName() == null)
                {
                    errors +=
                        "MISSING VALUE - Name is required for individual customers when countrycode is NL. Use SetName().\n";
                }
            }

            //Company
            if (order.GetIsCompanyIdentity())
            {
                if (order.GetCompanyCustomer().GetVatNumber() == null)
                {
                    errors +=
                        "MISSING VALUE - Vat number is required for company customers when countrycode is NL. Use SetVatNumber().\n";
                }
                if (order.GetCompanyCustomer().GetCompanyName() == null)
                {
                    errors +=
                        "MISSING VALUE - Company name is required for individual customers when countrycode is NL. Use SetName().\n";
                }
            }

            //Individual and Company
            if (order.GetCustomerIdentity().Street == null || order.GetCustomerIdentity().HouseNumber == null)
            {
                errors +=
                    "MISSING VALUE - Street address and house number is required for all customers when countrycode is NL. Use SetStreetAddress().\n";
            }
            if (order.GetCustomerIdentity().Locality == null)
            {
                errors +=
                    "MISSING VALUE - Locality is required for all customers when countrycode is NL. Use SetLocality().\n";
            }
            if (order.GetCustomerIdentity().ZipCode == null)
            {
                errors +=
                    "MISSING VALUE - Zip code is required for all customers when countrycode is NL. Use SetZipCode().\n";
            }

            return errors;
        }
        public void TestCustomerIdentity()
        {
            _order = CreateTestCustomerIdentity(_order);

            Assert.That(_order.GetIndividualCustomer().GetInitials(), Is.EqualTo("SB"));
            Assert.That(_order.GetIndividualCustomer().NationalIdNumber, Is.EqualTo("194605092222"));
            Assert.That(_order.GetIndividualCustomer().GetFirstName(), Is.EqualTo("Tess"));
            Assert.That(_order.GetIndividualCustomer().GetLastName(), Is.EqualTo("Persson"));
            Assert.That(_order.GetIndividualCustomer().GetBirthDate(), Is.EqualTo("19231212"));
            Assert.That(_order.GetIndividualCustomer().Email, Is.EqualTo("*****@*****.**"));
            Assert.That(_order.GetIndividualCustomer().PhoneNumber, Is.EqualTo("0811111111"));
            Assert.That(_order.GetIndividualCustomer().IpAddress, Is.EqualTo("123.123.123"));
            Assert.That(_order.GetIndividualCustomer().Street, Is.EqualTo("Testgatan"));
            Assert.That(_order.GetIndividualCustomer().HouseNumber, Is.EqualTo("1"));
            Assert.That(_order.GetIndividualCustomer().CoAddress, Is.EqualTo("c/o Eriksson, Erik"));
            Assert.That(_order.GetIndividualCustomer().ZipCode, Is.EqualTo("99999"));
            Assert.That(_order.GetIndividualCustomer().Locality, Is.EqualTo("Stan"));
        }
Exemplo n.º 4
0
        private void SerializeCustomer(CreateOrderBuilder order, XmlWriter xmlw)
        {
            if (order.GetCustomerIdentity() == null)
            {
                return;
            }

            CustomerIdentity        customer;
            Action <string, string> doWriteSimple = (name, value) => WriteSimpleElement(name, value, xmlw);

            if (order.GetIsCompanyIdentity())
            {
                customer = order.GetCompanyCustomer();
            }
            else
            {
                customer = order.GetIndividualCustomer();
            }

            xmlw.WriteStartElement("customer");

            if (customer.NationalIdNumber != null) //nordic country individual customer type
            {
                doWriteSimple("ssn", customer.NationalIdNumber);
            }
            else if (!order.GetIsCompanyIdentity()) //euro country individual
            {
                doWriteSimple("ssn", customer.IndividualIdentity.BirthDate);
            }
            else if (order.GetIsCompanyIdentity() && order.GetCountryCode() != CountryCode.SE)
            //euro country, Company customer and nationalId not set
            {
                doWriteSimple("ssn", customer.CompanyIdentity.CompanyVatNumber);
            }

            //Individual customer
            if (!order.GetIsCompanyIdentity())
            {
                var individualIdentity = customer.IndividualIdentity;
                if (individualIdentity != null)
                {
                    doWriteSimple("firstname", individualIdentity.FirstName);
                    doWriteSimple("lastname", individualIdentity.LastName);
                    doWriteSimple("initials", individualIdentity.Initials);
                }
            }
            else //Company customer
            {
                doWriteSimple("firstname", customer.FullName);
            }

            //Address
            doWriteSimple("phone", customer.PhoneNumber);
            doWriteSimple("email", customer.Email);
            doWriteSimple("address", customer.Street);
            doWriteSimple("housenumber", customer.HouseNumber);
            doWriteSimple("address2", customer.CoAddress);
            doWriteSimple("zip", customer.ZipCode);
            doWriteSimple("city", customer.Locality);

            if (order.GetCountryCode() != CountryCode.NONE)
            {
                doWriteSimple("country", order.GetCountryCode().ToString().ToUpper());
            }

            xmlw.WriteEndElement();

            doWriteSimple("ipaddress",
                          order.GetIsCompanyIdentity()
                              ? order.GetCompanyCustomer().GetIpAddress()
                              : order.GetIndividualCustomer().GetIpAddress());
        }
        public void TestCustomerIdentity()
        {
            _order = CreateTestCustomerIdentity(_order);

            Assert.That(_order.GetIndividualCustomer().GetInitials(), Is.EqualTo("SB"));
            Assert.That(_order.GetIndividualCustomer().NationalIdNumber, Is.EqualTo("194605092222"));
            Assert.That(_order.GetIndividualCustomer().GetFirstName(), Is.EqualTo("Tess"));
            Assert.That(_order.GetIndividualCustomer().GetLastName(), Is.EqualTo("Persson"));
            Assert.That(_order.GetIndividualCustomer().GetBirthDate(), Is.EqualTo("19231212"));
            Assert.That(_order.GetIndividualCustomer().Email, Is.EqualTo("*****@*****.**"));
            Assert.That(_order.GetIndividualCustomer().PhoneNumber, Is.EqualTo("0811111111"));
            Assert.That(_order.GetIndividualCustomer().IpAddress, Is.EqualTo("123.123.123"));
            Assert.That(_order.GetIndividualCustomer().Street, Is.EqualTo("Testgatan"));
            Assert.That(_order.GetIndividualCustomer().HouseNumber, Is.EqualTo("1"));
            Assert.That(_order.GetIndividualCustomer().CoAddress, Is.EqualTo("c/o Eriksson, Erik"));
            Assert.That(_order.GetIndividualCustomer().ZipCode, Is.EqualTo("99999"));
            Assert.That(_order.GetIndividualCustomer().Locality, Is.EqualTo("Stan"));
        }
        private void SerializeCustomer(CreateOrderBuilder order, XmlWriter xmlw)
        {
            if (order.GetCustomerIdentity() == null)
            {
                return;
            }

            CustomerIdentity customer;
            Action<string, string> doWriteSimple = (name, value) => WriteSimpleElement(name, value, xmlw);

            if (order.GetIsCompanyIdentity())
            {
                customer = order.GetCompanyCustomer();
            }
            else
            {
                customer = order.GetIndividualCustomer();
            }

            xmlw.WriteStartElement("customer");

            if (customer.NationalIdNumber != null) //nordic country individual customer type
            {
                doWriteSimple("ssn", customer.NationalIdNumber);
            }
            else if (!order.GetIsCompanyIdentity()) //euro country individual
            {
                doWriteSimple("ssn", customer.IndividualIdentity.BirthDate);
            }
            else if (order.GetIsCompanyIdentity() && order.GetCountryCode() != CountryCode.SE)
                //euro country, Company customer and nationalId not set
            {
                doWriteSimple("ssn", customer.CompanyIdentity.CompanyVatNumber);
            }

            //Individual customer
            if (!order.GetIsCompanyIdentity())
            {
                var individualIdentity = customer.IndividualIdentity;
                if (individualIdentity != null)
                {
                    doWriteSimple("firstname", individualIdentity.FirstName);
                    doWriteSimple("lastname", individualIdentity.LastName);
                    doWriteSimple("initials", individualIdentity.Initials);
                }
            }
            else //Company customer
            {
                doWriteSimple("firstname", customer.FullName);
            }

            //Address
            doWriteSimple("phone", customer.PhoneNumber);
            doWriteSimple("email", customer.Email);
            doWriteSimple("address", customer.Street);
            doWriteSimple("housenumber", customer.HouseNumber);
            doWriteSimple("address2", customer.CoAddress);
            doWriteSimple("zip", customer.ZipCode);
            doWriteSimple("city", customer.Locality);

            if (order.GetCountryCode() != CountryCode.NONE)
            {
                doWriteSimple("country", order.GetCountryCode().ToString().ToUpper());
            }

            xmlw.WriteEndElement();

            doWriteSimple("ipaddress",
                          order.GetIsCompanyIdentity()
                              ? order.GetCompanyCustomer().GetIpAddress()
                              : order.GetIndividualCustomer().GetIpAddress());
        }