コード例 #1
0
        ///// <summary>
        ///// Disable customer
        ///// </summary>
        //public void Disable()
        //{
        //    if (IsEnabled)
        //        this._IsEnabled = false;
        //}
        ///// <summary>
        ///// Enable customer
        ///// </summary>
        //public void Enable()
        //{
        //    if (!IsEnabled)
        //        this._IsEnabled = true;
        //}
        /// <summary>
        /// Associate existing country to this customer
        /// </summary>
        /// <param name="country"></param>
        public void SetTheCountryForThisCustomer(Country country)
        {
            if (country == null)
            {
                throw new ArgumentException(Messages.exception_CannotAssociateTransientOrNullCountry);
            }

            //fix relation
            this.CountryId = country.Id;

            this.Country = country;
        }
コード例 #2
0
        ///// <summary>
        ///// Change the customer credit limit
        ///// </summary>
        ///// <param name="newCredit">the new credit limit</param>
        //public void ChangeTheCurrentCredit(decimal newCredit)
        //{
        //    if (IsEnabled)
        //        this.CreditLimit = newCredit;
        //}
        public static Customer CreateCustomer(string firstName, 
                                                string lastName, 
                                                string telephone,
                                                string company,
                                                Country country, 
                                                Address address)
        {
            //create new instance and set identity
            var customer = new Customer();

            //set data

            customer.FirstName = firstName;
            customer.LastName = lastName;

            customer.Company = company;
            customer.Telephone = telephone;

            //set address
            customer.Address = address;

            //TODO: By default this is the limit for customer credit, you can set this
            //parameter customizable via configuration or other system
            customer.CreditLimit = 10000;

            //set the country for this customer
            customer.SetTheCountryForThisCustomer(country);

            return customer;
        }