internal static CustomerAcctSupportMapDto GetCustomerAcctSupportMap(Rbr_Db pDb, short pCustomerAcctId, int pVendorId) { CustomerAcctSupportMapRow _customerAcctSupportMapRow = pDb.CustomerAcctSupportMapCollection.GetByPrimaryKey(pCustomerAcctId, pVendorId); CustomerAcctDto _customerAcct = CustomerAcctManager.GetAcct(pDb, pCustomerAcctId); return(mapToCustomerAcctSupportMap(_customerAcctSupportMapRow, _customerAcct)); }
internal static void AddCustomerSupportVendor(Rbr_Db pDb, CustomerAcctSupportMapDto pCustomerAcctSupportMap) { CustomerAcctSupportMapRow _customerAcctSupportMapRow = mapToCustomerAcctSupportMapRow(pCustomerAcctSupportMap); if (_customerAcctSupportMapRow != null) { pDb.CustomerAcctSupportMapCollection.Insert(_customerAcctSupportMapRow); } }
//----------------------------------- Privates ---------------------------------------------------------- #region privates static CustomerAcctSupportMapRow mapToCustomerAcctSupportMapRow(CustomerAcctSupportMapDto pCustomerAcctSupportMap) { if (pCustomerAcctSupportMap == null) { return(null); } CustomerAcctSupportMapRow _customerAcctSupportMapRow = new CustomerAcctSupportMapRow(); _customerAcctSupportMapRow.Customer_acct_id = pCustomerAcctSupportMap.CustomerAcctId; _customerAcctSupportMapRow.Vendor_id = pCustomerAcctSupportMap.VendorId; return(_customerAcctSupportMapRow); }
/// <summary> /// Adds a new record into the <c>CustomerAcctSupportMap</c> table. /// </summary> /// <param name="value">The <see cref="CustomerAcctSupportMapRow"/> object to be inserted.</param> public virtual void Insert(CustomerAcctSupportMapRow value) { string sqlStr = "INSERT INTO [dbo].[CustomerAcctSupportMap] (" + "[customer_acct_id], " + "[vendor_id]" + ") VALUES (" + _db.CreateSqlParameterName("Customer_acct_id") + ", " + _db.CreateSqlParameterName("Vendor_id") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id); AddParameter(cmd, "Vendor_id", value.Vendor_id); cmd.ExecuteNonQuery(); }
static CustomerAcctSupportMapDto mapToCustomerAcctSupportMap(CustomerAcctSupportMapRow pCustomerAcctSupportMapRow, CustomerAcctDto pCustomerAcct) { if (pCustomerAcct == null) { return(null); } CustomerAcctSupportMapDto _customerAcctSupportMap = new CustomerAcctSupportMapDto(); _customerAcctSupportMap.CustomerAcctId = pCustomerAcct.CustomerAcctId; _customerAcctSupportMap.CustomerAcct = pCustomerAcct; if (pCustomerAcctSupportMapRow != null) { _customerAcctSupportMap.VendorId = pCustomerAcctSupportMapRow.Vendor_id; } _customerAcctSupportMap.Assigned = _customerAcctSupportMap.VendorId != 0; return(_customerAcctSupportMap); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="CustomerAcctSupportMapRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="CustomerAcctSupportMapRow"/> object.</returns> protected virtual CustomerAcctSupportMapRow MapRow(DataRow row) { CustomerAcctSupportMapRow mappedObject = new CustomerAcctSupportMapRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Customer_acct_id" dataColumn = dataTable.Columns["Customer_acct_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Customer_acct_id = (short)row[dataColumn]; } // Column "Vendor_id" dataColumn = dataTable.Columns["Vendor_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Vendor_id = (int)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="CustomerAcctSupportMapRow"/> objects.</returns> protected virtual CustomerAcctSupportMapRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int customer_acct_idColumnIndex = reader.GetOrdinal("customer_acct_id"); int vendor_idColumnIndex = reader.GetOrdinal("vendor_id"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { CustomerAcctSupportMapRow record = new CustomerAcctSupportMapRow(); recordList.Add(record); record.Customer_acct_id = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex)); record.Vendor_id = Convert.ToInt32(reader.GetValue(vendor_idColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((CustomerAcctSupportMapRow[])(recordList.ToArray(typeof(CustomerAcctSupportMapRow)))); }
/// <summary> /// Deletes the specified object from the <c>CustomerAcctSupportMap</c> table. /// </summary> /// <param name="value">The <see cref="CustomerAcctSupportMapRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(CustomerAcctSupportMapRow value) { return(DeleteByPrimaryKey(value.Customer_acct_id, value.Vendor_id)); }