コード例 #1
0
ファイル: Person.cs プロジェクト: pachinko/naa4e
 public static Person CreateNewEntry(string firstName, string lastName, DateTime? dateOfBirth)
 {
     var e = new PersonRegisteredEvent(Guid.NewGuid(), firstName, lastName);
     var p = new Person();
     p.RaiseEvent(e);
     return p;
 }
コード例 #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);
            }
コード例 #3
0
ファイル: Person.cs プロジェクト: stalla/NAAE
            public static Person CreateNewEntry(string firstName, string lastName, DateTime?dateOfBirth)
            {
                var e = new PersonRegisteredEvent(Guid.NewGuid(), firstName, lastName);
                var p = new Person();

                p.RaiseEvent(e);
                return(p);
            }
コード例 #4
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);
            }
コード例 #5
0
ファイル: Person.cs プロジェクト: emanbuc/M.NetAAE2
            public static Person CreateNewEntry(string firstName, string lastName, DateTime?dateOfBirth)
            {
                var p = new Person()
                {
                    Id        = Guid.NewGuid(),
                    FirstName = firstName,
                    LastName  = lastName
                };
                var e = new PersonRegisteredEvent(p.Id, p.FirstName, p.LastName);

                p.RaiseEvent(e);
                return(p);
            }
コード例 #6
0
ファイル: Person.cs プロジェクト: mtemel123/Merp
            public static Person CreateNewEntry(string firstName, string lastName, DateTime?dateOfBirth)
            {
                if (string.IsNullOrWhiteSpace(firstName))
                {
                    throw new ArgumentException("The first name must be specified", nameof(firstName));
                }
                if (string.IsNullOrWhiteSpace(lastName))
                {
                    throw new ArgumentException("The first name must be specified", nameof(lastName));
                }

                var e = new PersonRegisteredEvent(Guid.NewGuid(), firstName, lastName);
                var p = new Person();

                p.RaiseEvent(e);
                return(p);
            }
コード例 #7
0
ファイル: Person.cs プロジェクト: pixelia-es/Merp
            /// <summary>
            /// Creates an instance of the Person aggregate
            /// </summary>
            /// <param name="personId">The aggregate Id</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, string firstName, string lastName, string nationalIdentificationNumber, string vatNumber)
            {
                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))
                {
                    throw new ArgumentException("The National Identification Number", nameof(nationalIdentificationNumber));
                }

                var e = new PersonRegisteredEvent(personId, firstName, lastName, nationalIdentificationNumber, vatNumber);
                var p = new Person();

                p.RaiseEvent(e);
                return(p);
            }