コード例 #1
0
        /// <summary>
        /// this only fires once user has accepted to move on
        /// </summary>
        /// <param name="buySellDoc"></param>
        private void update_Customer_Person_Bill_To_Default_Address_If_empty(BuySellDoc buySellDoc)
        {
            buySellDoc.IsNullThrowException();
            buySellDoc.CustomerId.IsNullOrWhiteSpaceThrowException();
            buySellDoc.AddressBillToId.IsNullOrWhiteSpaceThrowException();
            Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId);

            customerPerson.IsNullThrowException();

            if (customerPerson.DefaultBillAddressId.IsNullOrEmpty())
            {
                customerPerson.DefaultBillAddressId = buySellDoc.AddressBillToId;
                PersonBiz.Update(customerPerson);
            }

            //Now update the Customer Default Address if required.
            //get the customer.
            Customer customer = buySellDoc.Customer;

            if (customer.IsNull())
            {
                buySellDoc.CustomerId.IsNullOrWhiteSpaceThrowException();
                customer = CustomerBiz.Find(buySellDoc.CustomerId);
                customer.IsNullThrowException();

                if (customer.DefaultBillAddressId.IsNullOrWhiteSpace())
                {
                    customer.DefaultBillAddressId = customerPerson.DefaultBillAddressId;
                    CustomerBiz.Update(customer);
                }
            }
        }