Inheritance: ContactCreditCardBase
Esempio n. 1
0
        /// <summary>
        ///     Inserts a Nettiers.AdventureWorks.Entities.ContactCreditCard object into the datasource using a transaction.
        /// </summary>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">Nettiers.AdventureWorks.Entities.ContactCreditCard object to insert.</param>
        /// <remarks>
        ///		After inserting into the datasource, the Nettiers.AdventureWorks.Entities.ContactCreditCard object will be updated
        ///     to refelect any changes made by the datasource. (ie: identity or computed columns)
        /// </remarks>
        /// <returns>Returns true if operation is successful.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Insert(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ContactCreditCard entity)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Sales.usp_adwTiers_ContactCreditCard_Insert", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@ContactId", DbType.Int32, entity.ContactId);
            database.AddInParameter(commandWrapper, "@CreditCardId", DbType.Int32, entity.CreditCardId);
            database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate);

            int results = 0;

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }


            entity.OriginalContactId    = entity.ContactId;
            entity.OriginalCreditCardId = entity.CreditCardId;

            entity.AcceptChanges();

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));

            return(Convert.ToBoolean(results));
        }
        /// <summary>
        /// Convert a nettiers entity to the ws proxy entity.
        /// </summary>
        public static WsProxy.ContactCreditCard Convert(Nettiers.AdventureWorks.Entities.ContactCreditCard item)
        {
            WsProxy.ContactCreditCard outItem = new WsProxy.ContactCreditCard();
            outItem.ContactId    = item.ContactId;
            outItem.CreditCardId = item.CreditCardId;
            outItem.ModifiedDate = item.ModifiedDate;

            outItem.OriginalContactId    = item.OriginalContactId;
            outItem.OriginalCreditCardId = item.OriginalCreditCardId;

            return(outItem);
        }
        /// <summary>
        /// Convert a nettiers collection to the ws proxy collection.
        /// </summary>
        public static Nettiers.AdventureWorks.Entities.ContactCreditCard Convert(Nettiers.AdventureWorks.Entities.ContactCreditCard outItem, WsProxy.ContactCreditCard item)
        {
            if (item != null && outItem != null)
            {
                outItem.ContactId    = item.ContactId;
                outItem.CreditCardId = item.CreditCardId;
                outItem.ModifiedDate = item.ModifiedDate;

                outItem.OriginalContactId    = item.ContactId;
                outItem.OriginalCreditCardId = item.CreditCardId;
                outItem.AcceptChanges();
            }

            return(outItem);
        }
        /// <summary>
        ///     Inserts a Nettiers.AdventureWorks.Entities.ContactCreditCard object into the datasource using a transaction.
        /// </summary>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">Nettiers.AdventureWorks.Entities.ContactCreditCard object to insert.</param>
        /// <remarks></remarks>
        /// <returns>Returns true if operation is successful.</returns>
        public override bool Insert(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ContactCreditCard entity)
        {
            WsProxy.AdventureWorksServices proxy = new WsProxy.AdventureWorksServices();
            proxy.Url = Url;

            try
            {
                WsProxy.ContactCreditCard result = proxy.ContactCreditCardProvider_Insert(Convert(entity));
                Convert(entity, result);
                return(true);
            }
            catch (SoapException soex)
            {
                System.Diagnostics.Debug.WriteLine(soex);
                throw soex;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                throw ex;
            }
        }
 /// <summary>
 /// Convert a nettiers collection to the ws proxy collection.
 /// </summary>
 public static Nettiers.AdventureWorks.Entities.ContactCreditCard Convert(WsProxy.ContactCreditCard item)
 {
     Nettiers.AdventureWorks.Entities.ContactCreditCard outItem = item == null ? null : new Nettiers.AdventureWorks.Entities.ContactCreditCard();
     Convert(outItem, item);
     return(outItem);
 }
		/// <summary>
        /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.)
        /// </summary>
        /// <param name="mock">Object to be modified</param>
        static private void SetSpecialTestData(ContactCreditCard mock)
        {
            //Code your changes to the data object here.
        }
        ///<summary>
        ///  Update the Typed ContactCreditCard Entity with modified mock values.
        ///</summary>
        static public void UpdateMockInstance(TransactionManager tm, ContactCreditCard mock)
        {
            ContactCreditCardTest.UpdateMockInstance_Generated(tm, mock);
            
			// make any alterations necessary 
            // (i.e. for DB check constraints, special test cases, etc.)
			SetSpecialTestData(mock);
        }