Esempio n. 1
0
 public RegisterPersonCommand(string firstName, string lastName, string nationalIdentificationNumber, string vatNumber, string address, string city, string postalCode, string province, string country, string phoneNumber, string mobileNumber, string faxNumber, string websiteAddress, string emailAddress, string instantMessaging)
 {
     if (string.IsNullOrWhiteSpace(firstName))
     {
         throw new ArgumentException("First name must be provided", nameof(firstName));
     }
     if (string.IsNullOrWhiteSpace(lastName))
     {
         throw new ArgumentException("Last name must be provided", nameof(lastName));
     }
     if (!PostalAddressHelper.IsValidAddress(address, city, postalCode, province, country))
     {
         throw new ArgumentException("postal address must either be empty or comprehensive of both address and city");
     }
     FirstName = firstName;
     LastName  = lastName;
     NationalIdentificationNumber = nationalIdentificationNumber;
     VatNumber        = vatNumber;
     Address          = address;
     City             = city;
     PostalCode       = postalCode;
     Province         = province;
     Country          = country;
     PhoneNumber      = phoneNumber;
     MobileNumber     = mobileNumber;
     FaxNumber        = faxNumber;
     WebsiteAddress   = websiteAddress;
     EmailAddress     = emailAddress;
     InstantMessaging = instantMessaging;
 }
Esempio n. 2
0
            /// <summary>
            /// Creates an instance of the Person aggregate
            /// </summary>
            /// <param name="personId">The aggregate Id</param>
            /// <param name="registrationDate">The date in which the person was registered</param>
            /// <param name="firstName">The person's first name</param>
            /// <param name="lastName">The person's last name</param>
            /// <param name="nationalIdentificationNumber">The person's National Identification Number</param>
            /// <param name="vatNumber">The person's VAT Number</param>
            /// <returns>The aggregate instance</returns>
            /// <exception cref="ArgumentException">Thrown if the firstName or the last name are null or empty</exception>
            public static Person CreateNewEntryByImport(Guid personId, DateTime registrationDate, string firstName, string lastName, string nationalIdentificationNumber, string vatNumber, string address, string city, string postalCode, string province, string country, string phoneNumber, string mobileNumber, string faxNumber, string websiteAddress, string emailAddress, string instantMessaging, Guid userId)
            {
                if (string.IsNullOrWhiteSpace(firstName))
                {
                    throw new ArgumentException("The first name must be specified", nameof(firstName));
                }

                if (string.IsNullOrWhiteSpace(lastName))
                {
                    throw new ArgumentException("The last name must be specified", nameof(lastName));
                }

                //if (!string.IsNullOrWhiteSpace(nationalIdentificationNumber))
                //{
                //    if (!NationalIdentificationNumberHelper.IsMatchingFirstName(nationalIdentificationNumber, firstName))
                //    {
                //        throw new ArgumentException("National identification number is not matching with first name", nameof(nationalIdentificationNumber));
                //    }
                //    if (!NationalIdentificationNumberHelper.IsMatchingLastName(nationalIdentificationNumber, lastName))
                //    {
                //        throw new ArgumentException("National identification number is not matching with last name", nameof(nationalIdentificationNumber));
                //    }
                //}
                if (!PostalAddressHelper.IsValidAddress(address, city, postalCode, province, country))
                {
                    throw new ArgumentException("postal address must either be empty or comprehensive of both address and city");
                }

                var e = new PersonRegisteredEvent(personId, registrationDate, firstName, lastName, nationalIdentificationNumber, vatNumber, address, city, postalCode, province, country, address, city, postalCode, province, country, address, city, postalCode, province, country, phoneNumber, mobileNumber, faxNumber, websiteAddress, emailAddress, instantMessaging, userId);
                var p = new Person();

                p.RaiseEvent(e);
                return(p);
            }
Esempio n. 3
0
        public ImportCompanyCommand(Guid companyId, string companyName, string vatNumber, string nationalIdentificationNumber, string address, string city, string postalCode, string province, string country)
        {
            if (string.IsNullOrWhiteSpace(companyName))
            {
                throw new ArgumentNullException(nameof(companyName));
            }
            if (string.IsNullOrWhiteSpace(vatNumber))
            {
                throw new ArgumentNullException(nameof(vatNumber));
            }
            if (!PostalAddressHelper.IsValidAddress(address, city, postalCode, province, country))
            {
                throw new ArgumentException("postal address must either be empty or comprehensive of both address and city");
            }

            CompanyId   = companyId;
            CompanyName = companyName;
            VatNumber   = vatNumber;
            NationalIdentificationNumber = nationalIdentificationNumber;
            Address    = address;
            City       = city;
            PostalCode = postalCode;
            Province   = province;
            Country    = country;
        }
Esempio n. 4
0
            public static Company CreateNewEntryByImport(Guid companyId, string companyName, string vatNumber, string nationalIdentificationNumber, string legalAddressAddress, string legalAddressCity, string legalAddressPostalCode, string legalAddressProvince, string legalAddressCountry)
            {
                if (string.IsNullOrWhiteSpace(companyName))
                {
                    throw new ArgumentException("The company name must be specified", nameof(companyName));
                }
                if (string.IsNullOrWhiteSpace(vatNumber))
                {
                    throw new ArgumentException("The VAT number must be specified", nameof(vatNumber));
                }
                if (string.IsNullOrEmpty(legalAddressAddress) && (!string.IsNullOrEmpty(legalAddressCity) || !string.IsNullOrEmpty(legalAddressCountry)))
                {
                    throw new ArgumentException("address must be specified when city and country are also specified", nameof(legalAddressAddress));
                }
                if (string.IsNullOrEmpty(legalAddressCity) && (!string.IsNullOrEmpty(legalAddressAddress) || !string.IsNullOrEmpty(legalAddressCountry)))
                {
                    throw new ArgumentException("city must be specified when address and country are also specified", nameof(legalAddressCity));
                }
                if (string.IsNullOrEmpty(legalAddressCountry) && (!string.IsNullOrEmpty(legalAddressAddress) || !string.IsNullOrEmpty(legalAddressCity)))
                {
                    throw new ArgumentException("country must be specified when address and country are also specified", nameof(legalAddressCountry));
                }
                if (!PostalAddressHelper.IsValidAddress(legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry))
                {
                    throw new ArgumentException("legal address must either be empty or comprehensive of both address and city");
                }
                var p = new Company();
                var e = new CompanyRegisteredEvent(companyId, companyName, vatNumber, nationalIdentificationNumber, legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry);

                p.RaiseEvent(e);
                return(p);
            }
Esempio n. 5
0
        public ImportPersonCommand(Guid personId, string firstName, string lastName, string nationalIdentificationNumber, string vatNumber, string address, string city, string postalCode, string province, string country)
        {
            if (string.IsNullOrWhiteSpace(firstName))
            {
                throw new ArgumentException("First name must be provided", nameof(firstName));
            }
            if (string.IsNullOrWhiteSpace(lastName))
            {
                throw new ArgumentException("Last name must be provided", nameof(lastName));
            }
            if (!PostalAddressHelper.IsValidAddress(address, city, postalCode, province, country))
            {
                throw new ArgumentException("postal address must either be empty or comprehensive of both address and city");
            }

            PersonId  = personId;
            FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName));
            LastName  = lastName ?? throw new ArgumentNullException(nameof(lastName));
            NationalIdentificationNumber = nationalIdentificationNumber;
            VatNumber  = vatNumber;
            Address    = address;
            City       = city;
            PostalCode = postalCode;
            Province   = province;
            Country    = country;
        }
Esempio n. 6
0
        public RegisterCompanyCommand(Guid userId, string companyName, string nationalIdentificationNumber, string vatNumber, string legalAddressAddress, string legalAddressPostalCode, string legalAddressCity, string legalAddressProvince, string legalAddressCountry, string shippingAddressAddress, string shippingAddressPostalCode, string shippingAddressCity, string shippingAddressProvince, string shippingAddressCountry, string billingAddressAddress, string billingAddressPostalCode, string billingAddressCity, string billingAddressProvince, string billingAddressCountry, Guid?mainContactId, Guid?administrativeContactId, string phoneNumber, string faxNumber, string websiteAddress, string emailAddress)
            : base(userId)
        {
            if (string.IsNullOrWhiteSpace(companyName))
            {
                throw new ArgumentException("Company name must be provided", nameof(companyName));
            }

            if (string.IsNullOrWhiteSpace(vatNumber))
            {
                throw new ArgumentException("Vat number must be provided", nameof(vatNumber));
            }

            if (!PostalAddressHelper.IsValidAddress(legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry))
            {
                throw new ArgumentException("legal address must either be empty or comprehensive of both address and city");
            }

            if (!PostalAddressHelper.IsValidAddress(shippingAddressAddress, shippingAddressCity, shippingAddressPostalCode, shippingAddressProvince, shippingAddressCountry))
            {
                throw new ArgumentException("shipping address must either be empty or comprehensive of both address and city");
            }

            if (!PostalAddressHelper.IsValidAddress(billingAddressAddress, billingAddressCity, billingAddressPostalCode, billingAddressProvince, billingAddressCountry))
            {
                throw new ArgumentException("billing address must either be empty or comprehensive of both address and city");
            }


            CompanyName = companyName;
            VatNumber   = vatNumber;
            NationalIdentificationNumber = nationalIdentificationNumber;

            LegalAddressAddress    = legalAddressAddress;
            LegalAddressPostalCode = legalAddressPostalCode;
            LegalAddressCity       = legalAddressCity;
            LegalAddressCountry    = legalAddressCountry;
            LegalAddressProvince   = legalAddressProvince;

            ShippingAddressAddress    = shippingAddressAddress;
            ShippingAddressPostalCode = shippingAddressPostalCode;
            ShippingAddressCity       = shippingAddressCity;
            ShippingAddressCountry    = shippingAddressCountry;
            ShippingAddressProvince   = shippingAddressProvince;

            BillingAddressAddress    = billingAddressAddress;
            BillingAddressPostalCode = billingAddressPostalCode;
            BillingAddressCity       = billingAddressCity;
            BillingAddressCountry    = billingAddressCountry;
            BillingAddressProvince   = billingAddressProvince;

            MainContactId           = mainContactId;
            AdministrativeContactId = administrativeContactId;
            PhoneNumber             = phoneNumber;
            FaxNumber      = faxNumber;
            WebsiteAddress = websiteAddress;
            EmailAddress   = emailAddress;
        }
Esempio n. 7
0
            /// <summary>
            /// Creates an instance of the Person aggregate
            /// </summary>
            /// <param name="firstName">The person's first name</param>
            /// <param name="lastName">The person's last name</param>
            /// <param name="nationalIdentificationNumber">The person's National Identification Number</param>
            /// <param name="vatNumber">The person's VAT Number</param>
            /// <returns>The aggregate instance</returns>
            /// <exception cref="ArgumentException">Thrown if the firstName or the last name are null or empty</exception>
            public static Person CreateNewEntry(string firstName, string lastName, string nationalIdentificationNumber, string vatNumber,
                                                string legalAddressAddress, string legalAddressCity, string legalAddressPostalCode, string legalAddressProvince, string legalAddressCountry,
                                                string billingAddressAddress, string billingAddressCity, string billingAddressPostalCode, string billingAddressProvince, string billingAddressCountry,
                                                string shippingAddressAddress, string shippingAddressCity, string shippingAddressPostalCode, string shippingAddressProvince, string shippingAddressCountry,
                                                string phoneNumber, string mobileNumber, string faxNumber, string websiteAddress, string emailAddress, string instantMessaging, Guid userId)
            {
                if (string.IsNullOrWhiteSpace(firstName))
                {
                    throw new ArgumentException("The first name must be specified", nameof(firstName));
                }

                if (string.IsNullOrWhiteSpace(lastName))
                {
                    throw new ArgumentException("The last name must be specified", nameof(lastName));
                }

                if (!string.IsNullOrWhiteSpace(nationalIdentificationNumber))
                {
                    if (!NationalIdentificationNumberHelper.IsMatchingFirstName(nationalIdentificationNumber, firstName))
                    {
                        throw new ArgumentException("National identification number is not matching with first name", nameof(nationalIdentificationNumber));
                    }
                    if (!NationalIdentificationNumberHelper.IsMatchingLastName(nationalIdentificationNumber, lastName))
                    {
                        throw new ArgumentException("National identification number is not matching with last name", nameof(nationalIdentificationNumber));
                    }
                }
                if (!PostalAddressHelper.IsValidAddress(legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry))
                {
                    throw new ArgumentException("legal address must either be empty or comprehensive of both address and city");
                }

                if (!PostalAddressHelper.IsValidAddress(shippingAddressAddress, shippingAddressCity, shippingAddressPostalCode, shippingAddressProvince, shippingAddressCountry))
                {
                    throw new ArgumentException("shipping address must either be empty or comprehensive of both address and city");
                }

                if (!PostalAddressHelper.IsValidAddress(billingAddressAddress, billingAddressCity, billingAddressPostalCode, billingAddressProvince, billingAddressCountry))
                {
                    throw new ArgumentException("billing address must either be empty or comprehensive of both address and city");
                }

                var personId         = Guid.NewGuid();
                var registrationDate = DateTime.Now;
                var e = new PersonRegisteredEvent(personId, registrationDate, firstName, lastName, nationalIdentificationNumber, vatNumber,
                                                  legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry,
                                                  billingAddressAddress, billingAddressCity, billingAddressPostalCode, billingAddressProvince, billingAddressCountry,
                                                  shippingAddressAddress, shippingAddressCity, shippingAddressPostalCode, shippingAddressProvince, shippingAddressCountry,
                                                  phoneNumber, mobileNumber, faxNumber, websiteAddress, emailAddress, instantMessaging, userId);
                var p = new Person();

                p.RaiseEvent(e);
                return(p);
            }
Esempio n. 8
0
 public RegisterPersonCommand(Guid userId, string firstName, string lastName, string nationalIdentificationNumber, string vatNumber, string legalAddressAddress, string legalAddressCity, string legalAddressPostalCode, string legalAddressProvince, string legalAddressCountry, string shippingAddressAddress, string shippingAddressPostalCode, string shippingAddressCity, string shippingAddressProvince, string shippingAddressCountry, string billingAddressAddress, string billingAddressPostalCode, string billingAddressCity, string billingAddressProvince, string billingAddressCountry, string phoneNumber, string mobileNumber, string faxNumber, string websiteAddress, string emailAddress, string instantMessaging)
     : base(userId)
 {
     if (string.IsNullOrWhiteSpace(firstName))
     {
         throw new ArgumentException("First name must be provided", nameof(firstName));
     }
     if (string.IsNullOrWhiteSpace(lastName))
     {
         throw new ArgumentException("Last name must be provided", nameof(lastName));
     }
     if (!PostalAddressHelper.IsValidAddress(legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry))
     {
         throw new ArgumentException("legal address must either be empty or comprehensive of both address and city");
     }
     if (!PostalAddressHelper.IsValidAddress(shippingAddressAddress, shippingAddressCity, shippingAddressPostalCode, shippingAddressProvince, shippingAddressCountry))
     {
         throw new ArgumentException("shipping address must either be empty or comprehensive of both address and city");
     }
     if (!PostalAddressHelper.IsValidAddress(billingAddressAddress, billingAddressCity, billingAddressPostalCode, billingAddressProvince, billingAddressCountry))
     {
         throw new ArgumentException("billing address must either be empty or comprehensive of both address and city");
     }
     FirstName = firstName;
     LastName  = lastName;
     NationalIdentificationNumber = nationalIdentificationNumber;
     VatNumber                 = vatNumber;
     LegalAddressAddress       = legalAddressAddress;
     LegalAddressCity          = legalAddressCity;
     LegalAddressPostalCode    = legalAddressPostalCode;
     LegalAddressProvince      = legalAddressProvince;
     LegalAddressCountry       = legalAddressCountry;
     ShippingAddressAddress    = shippingAddressAddress;
     ShippingAddressPostalCode = shippingAddressPostalCode;
     ShippingAddressCity       = shippingAddressCity;
     ShippingAddressProvince   = shippingAddressProvince;
     ShippingAddressCountry    = shippingAddressCountry;
     BillingAddressAddress     = billingAddressAddress;
     BillingAddressPostalCode  = billingAddressPostalCode;
     BillingAddressCity        = billingAddressCity;
     BillingAddressProvince    = billingAddressProvince;
     BillingAddressCountry     = billingAddressCountry;
     PhoneNumber               = phoneNumber;
     MobileNumber              = mobileNumber;
     FaxNumber                 = faxNumber;
     WebsiteAddress            = websiteAddress;
     EmailAddress              = emailAddress;
     InstantMessaging          = instantMessaging;
 }
Esempio n. 9
0
        public ImportPersonCommand(Guid userId, Guid personId, DateTime registrationDate, string firstName, string lastName, string nationalIdentificationNumber, string vatNumber, string address, string city, string postalCode, string province, string country, string phoneNumber, string mobileNumber, string faxNumber, string websiteAddress, string emailAddress, string instantMessaging)
            : base(userId)
        {
            if (personId == Guid.Empty)
            {
                throw new ArgumentException("A non-empty personId should be provided", nameof(personId));
            }

            if (string.IsNullOrWhiteSpace(firstName))
            {
                throw new ArgumentException("First name must be provided", nameof(firstName));
            }

            if (string.IsNullOrWhiteSpace(lastName))
            {
                throw new ArgumentException("Last name must be provided", nameof(lastName));
            }

            if (!PostalAddressHelper.IsValidAddress(address, city, postalCode, province, country))
            {
                throw new ArgumentException("postal address must either be empty or comprehensive of both address and city");
            }

            PersonId                     = personId;
            RegistrationDate             = registrationDate;
            FirstName                    = firstName;
            LastName                     = lastName;
            NationalIdentificationNumber = nationalIdentificationNumber;
            VatNumber                    = vatNumber;
            Address          = address;
            City             = city;
            PostalCode       = postalCode;
            Province         = province;
            Country          = country;
            PhoneNumber      = phoneNumber;
            MobileNumber     = mobileNumber;
            FaxNumber        = faxNumber;
            WebsiteAddress   = websiteAddress;
            EmailAddress     = emailAddress;
            InstantMessaging = instantMessaging;
        }