/// <summary>
        ///     Update an existing row in the datasource.
        /// </summary>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">Nettiers.AdventureWorks.Entities.ProductVendor object to update.</param>
        /// <remarks>
        ///		After updating the datasource, the Nettiers.AdventureWorks.Entities.ProductVendor 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 Update(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ProductVendor entity)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Purchasing.usp_adwTiers_ProductVendor_Update", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@ProductId", DbType.Int32, entity.ProductId);
            database.AddInParameter(commandWrapper, "@OriginalProductId", DbType.Int32, entity.OriginalProductId);
            database.AddInParameter(commandWrapper, "@VendorId", DbType.Int32, entity.VendorId);
            database.AddInParameter(commandWrapper, "@OriginalVendorId", DbType.Int32, entity.OriginalVendorId);
            database.AddInParameter(commandWrapper, "@AverageLeadTime", DbType.Int32, entity.AverageLeadTime);
            database.AddInParameter(commandWrapper, "@StandardPrice", DbType.Currency, entity.StandardPrice);
            database.AddInParameter(commandWrapper, "@LastReceiptCost", DbType.Currency, (entity.LastReceiptCost.HasValue ? (object)entity.LastReceiptCost : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@LastReceiptDate", DbType.DateTime, (entity.LastReceiptDate.HasValue ? (object)entity.LastReceiptDate : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@MinOrderQty", DbType.Int32, entity.MinOrderQty);
            database.AddInParameter(commandWrapper, "@MaxOrderQty", DbType.Int32, entity.MaxOrderQty);
            database.AddInParameter(commandWrapper, "@OnOrderQty", DbType.Int32, (entity.OnOrderQty.HasValue ? (object)entity.OnOrderQty : System.DBNull.Value));
            database.AddInParameter(commandWrapper, "@UnitMeasureCode", DbType.StringFixedLength, entity.UnitMeasureCode);
            database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, entity.ModifiedDate);

            int results = 0;

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

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

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                EntityManager.StopTracking(entity.EntityTrackingKey);
            }

            entity.OriginalProductId = entity.ProductId;
            entity.OriginalVendorId  = entity.VendorId;

            entity.AcceptChanges();

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

            return(Convert.ToBoolean(results));
        }
Beispiel #2
0
        /// <summary>
        /// Convert a nettiers collection to the ws proxy collection.
        /// </summary>
        public static Nettiers.AdventureWorks.Entities.ProductVendor Convert(Nettiers.AdventureWorks.Entities.ProductVendor outItem, WsProxy.ProductVendor item)
        {
            if (item != null && outItem != null)
            {
                outItem.ProductId       = item.ProductId;
                outItem.VendorId        = item.VendorId;
                outItem.AverageLeadTime = item.AverageLeadTime;
                outItem.StandardPrice   = item.StandardPrice;
                outItem.LastReceiptCost = item.LastReceiptCost;
                outItem.LastReceiptDate = item.LastReceiptDate;
                outItem.MinOrderQty     = item.MinOrderQty;
                outItem.MaxOrderQty     = item.MaxOrderQty;
                outItem.OnOrderQty      = item.OnOrderQty;
                outItem.UnitMeasureCode = item.UnitMeasureCode;
                outItem.ModifiedDate    = item.ModifiedDate;

                outItem.OriginalProductId = item.ProductId;
                outItem.OriginalVendorId  = item.VendorId;
                outItem.AcceptChanges();
            }

            return(outItem);
        }
Beispiel #3
0
        /// <summary>
        ///     Update an existing row in the datasource.
        /// </summary>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">Nettiers.AdventureWorks.Entities.ProductVendor object to update.</param>
        /// <remarks></remarks>
        /// <returns>Returns true if operation is successful.</returns>
        public override bool Update(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ProductVendor entity)
        {
            WsProxy.AdventureWorksServices proxy = new WsProxy.AdventureWorksServices();
            proxy.Url = Url;

            try
            {
                WsProxy.ProductVendor result = proxy.ProductVendorProvider_Update(Convert(entity));
                Convert(entity, result);
                entity.AcceptChanges();
                return(true);
            }
            catch (SoapException soex)
            {
                System.Diagnostics.Debug.WriteLine(soex);
                throw soex;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                throw ex;
            }
        }