예제 #1
0
        /// <summary>
        /// Validates Customer information before Saving Customer
        /// Properties to the database
        /// </summary>
        private void Save()
        {
            if (String.IsNullOrEmpty(_name))
                throw new ArgumentException("Customer Name not supplied", "name");
            if (_name.Length > 50)
                throw new ArgumentException("Customer Name must be less than 50 characters", "name");
            if (String.IsNullOrEmpty(_address))
                throw new ArgumentException("Customer Address not supplied", "address");

            SqlDataAccessLayer dataAccessLayer = new SqlDataAccessLayer();
            if (_id > 0)
                dataAccessLayer.CustomerUpdate(this);
            else
                dataAccessLayer.CustomerInsert(this);
        }