internal static CustomerSupportVendorDto GetCustomerSupportVendor(Rbr_Db pDb, int pVendorId)
        {
            CustomerSupportVendorRow _customerSupportVendorRow = pDb.CustomerSupportVendorCollection.GetByPrimaryKey(pVendorId);
            ContactInfoDto           _contactInfo = ContactInfoManager.Get(pDb, _customerSupportVendorRow.Contact_info_id);

            return(mapToCustomerSupportVendor(_customerSupportVendorRow, _contactInfo));
        }
Esempio n. 2
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="CustomerSupportVendorRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="CustomerSupportVendorRow"/> object.</returns>
        protected virtual CustomerSupportVendorRow MapRow(DataRow row)
        {
            CustomerSupportVendorRow mappedObject = new CustomerSupportVendorRow();
            DataTable  dataTable = row.Table;
            DataColumn dataColumn;

            // Column "Vendor_id"
            dataColumn = dataTable.Columns["Vendor_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Vendor_id = (int)row[dataColumn];
            }
            // Column "Name"
            dataColumn = dataTable.Columns["Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Name = (string)row[dataColumn];
            }
            // Column "Contact_info_id"
            dataColumn = dataTable.Columns["Contact_info_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Contact_info_id = (int)row[dataColumn];
            }
            return(mappedObject);
        }
        internal static void DeleteCustomerSupportVendor(Rbr_Db pDb, int pVendorId)
        {
            CustomerSupportVendorRow _customerSupportVendorRow = pDb.CustomerSupportVendorCollection.GetByPrimaryKey(pVendorId);

            pDb.CustomerSupportVendorCollection.DeleteByPrimaryKey(pVendorId);
            pDb.ContactInfoCollection.GetByPrimaryKey(_customerSupportVendorRow.Contact_info_id);
        }
        static CustomerSupportVendorDto mapToCustomerSupportVendor(CustomerSupportVendorRow pCustomerSupportVendorRow, ContactInfoDto pContactInfo)
        {
            if (pCustomerSupportVendorRow == null)
            {
                return(null);
            }
            CustomerSupportVendorDto _customerSupportVendor = new CustomerSupportVendorDto();

            _customerSupportVendor.VendorId    = pCustomerSupportVendorRow.Vendor_id;
            _customerSupportVendor.Name        = pCustomerSupportVendorRow.Name;
            _customerSupportVendor.ContactInfo = pContactInfo;

            return(_customerSupportVendor);
        }
        static CustomerSupportVendorRow mapToCustomerSupportVendorRow(CustomerSupportVendorDto pCustomerSupportVendor)
        {
            if (pCustomerSupportVendor == null)
            {
                return(null);
            }
            CustomerSupportVendorRow _customerSupportVendorRow = new CustomerSupportVendorRow();

            _customerSupportVendorRow.Vendor_id       = pCustomerSupportVendor.VendorId;
            _customerSupportVendorRow.Name            = pCustomerSupportVendor.Name;
            _customerSupportVendorRow.Contact_info_id = pCustomerSupportVendor.ContactInfo.ContactInfoId;

            return(_customerSupportVendorRow);
        }
Esempio n. 6
0
        /// <summary>
        /// Updates a record in the <c>CustomerSupportVendor</c> table.
        /// </summary>
        /// <param name="value">The <see cref="CustomerSupportVendorRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(CustomerSupportVendorRow value)
        {
            string sqlStr = "UPDATE [dbo].[CustomerSupportVendor] SET " +
                            "[name]=" + _db.CreateSqlParameterName("Name") + ", " +
                            "[contact_info_id]=" + _db.CreateSqlParameterName("Contact_info_id") +
                            " WHERE " +
                            "[vendor_id]=" + _db.CreateSqlParameterName("Vendor_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Contact_info_id", value.Contact_info_id);
            AddParameter(cmd, "Vendor_id", value.Vendor_id);
            return(0 != cmd.ExecuteNonQuery());
        }
        internal static void SaveCustomerSupportVendor(Rbr_Db pDb, CustomerSupportVendorDto pCustomerSupportVendor)
        {
            CustomerSupportVendorRow _customerSupportVendorRow = mapToCustomerSupportVendorRow(pCustomerSupportVendor);

            if (_customerSupportVendorRow != null)
            {
                if (_customerSupportVendorRow.Vendor_id == 0)
                {
                    pDb.CustomerSupportVendorCollection.Insert(_customerSupportVendorRow);
                    pCustomerSupportVendor.VendorId = _customerSupportVendorRow.Vendor_id;
                }
                else
                {
                    pDb.CustomerSupportVendorCollection.Update(_customerSupportVendorRow);
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Adds a new record into the <c>CustomerSupportVendor</c> table.
        /// </summary>
        /// <param name="value">The <see cref="CustomerSupportVendorRow"/> object to be inserted.</param>
        public virtual void Insert(CustomerSupportVendorRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[CustomerSupportVendor] (" +
                            "[vendor_id], " +
                            "[name], " +
                            "[contact_info_id]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Vendor_id") + ", " +
                            _db.CreateSqlParameterName("Name") + ", " +
                            _db.CreateSqlParameterName("Contact_info_id") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Vendor_id", value.Vendor_id);
            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Contact_info_id", value.Contact_info_id);
            cmd.ExecuteNonQuery();
        }
Esempio n. 9
0
        /// <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="CustomerSupportVendorRow"/> objects.</returns>
        protected virtual CustomerSupportVendorRow[] 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 vendor_idColumnIndex       = reader.GetOrdinal("vendor_id");
            int nameColumnIndex            = reader.GetOrdinal("name");
            int contact_info_idColumnIndex = reader.GetOrdinal("contact_info_id");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    CustomerSupportVendorRow record = new CustomerSupportVendorRow();
                    recordList.Add(record);

                    record.Vendor_id       = Convert.ToInt32(reader.GetValue(vendor_idColumnIndex));
                    record.Name            = Convert.ToString(reader.GetValue(nameColumnIndex));
                    record.Contact_info_id = Convert.ToInt32(reader.GetValue(contact_info_idColumnIndex));

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((CustomerSupportVendorRow[])(recordList.ToArray(typeof(CustomerSupportVendorRow))));
        }
Esempio n. 10
0
 /// <summary>
 /// Deletes the specified object from the <c>CustomerSupportVendor</c> table.
 /// </summary>
 /// <param name="value">The <see cref="CustomerSupportVendorRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(CustomerSupportVendorRow value)
 {
     return(DeleteByPrimaryKey(value.Vendor_id));
 }