Beispiel #1
0
 public static Company CreateNewEntry(string companyName, string vatIndex)
 {
     var p = new Company();
     var e = new CompanyRegisteredEvent(Guid.NewGuid(), companyName, vatIndex);
     p.RaiseEvent(e);
     return p;
 }
Beispiel #2
0
            public static Company CreateNewEntry(string companyName, string vatNumber, string nationalIdentificationNumber,
                                                 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, Guid userId)
            {
                if (string.IsNullOrWhiteSpace(companyName))
                {
                    throw new ArgumentException("The company name must be specified", nameof(companyName));
                }

                if (string.IsNullOrWhiteSpace(nationalIdentificationNumber) && string.IsNullOrWhiteSpace(vatNumber))
                {
                    throw new ArgumentException("Either the VAT number or the NIN must be specified", nameof(vatNumber));
                }

                var companyId = Guid.NewGuid();
                var p         = new Company();
                var e         = new CompanyRegisteredEvent(companyId, DateTime.Now, companyName, vatNumber, nationalIdentificationNumber,
                                                           legalAddressAddress, legalAddressCity, legalAddressPostalCode, legalAddressProvince, legalAddressCountry,
                                                           billingAddressAddress, billingAddressCity, billingAddressPostalCode, billingAddressProvince, billingAddressCountry,
                                                           shippingAddressAddress, shippingAddressCity, shippingAddressPostalCode, shippingAddressProvince, shippingAddressCountry, userId);

                p.RaiseEvent(e);
                return(p);
            }
Beispiel #3
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);
            }
Beispiel #4
0
            public static Company CreateNewEntry(string companyName, string vatIndex)
            {
                var p = new Company();
                var e = new CompanyRegisteredEvent(Guid.NewGuid(), companyName, vatIndex);

                p.RaiseEvent(e);
                return(p);
            }
Beispiel #5
0
            public static Company CreateNewEntry(string companyName, string vatIndex)
            {
                var p = new Company()
                {
                    Id          = Guid.NewGuid(),
                    CompanyName = companyName,
                    VatIndex    = vatIndex
                };
                var e = new CompanyRegisteredEvent(p.Id, p.CompanyName, p.VatIndex);

                p.RaiseEvent(e);
                return(p);
            }
Beispiel #6
0
            public static Company CreateNewEntryByImport(Guid companyId, string companyName, string vatNumber, string nationalIdentificationNumber)
            {
                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));
                }

                var p = new Company();
                var e = new CompanyRegisteredEvent(companyId, companyName, vatNumber, nationalIdentificationNumber);

                p.RaiseEvent(e);
                return(p);
            }
Beispiel #7
0
            public static Company CreateNewEntry(string companyName, string vatIndex)
            {
                if (string.IsNullOrWhiteSpace(companyName))
                {
                    throw new ArgumentException("The company name must be specified", nameof(companyName));
                }
                if (string.IsNullOrWhiteSpace(vatIndex))
                {
                    throw new ArgumentException("The VAT index must be specified", nameof(vatIndex));
                }

                var p = new Company();
                var e = new CompanyRegisteredEvent(Guid.NewGuid(), companyName, vatIndex);

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