コード例 #1
0
        /// <summary>
        /// 删除客户地址
        /// </summary>
        /// <param name="id">Id</param>
        public void Delete(string id)
        {
            using (DbConnection conn = DbHelper.CreateConnection())
            {
                DbTransaction trans = null;
                try
                {
                    conn.Open();
                    trans = conn.BeginTransaction();
                    if (trans == null)
                    {
                        throw new ArgumentNullException("DbTransaction");
                    }

                    CustomerAddress entity = this.Select(trans, id);
                    if (!entity.CanDelete())
                    {
                        throw new EasySoftException(BusinessResource.Customer_NotAllowDeleteDefaultAddress);
                    }
                    this.customerAddressRepository.Delete(trans, id);
                    trans.Commit();
                }
                catch
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    throw;
                }
            }
        }