Beispiel #1
0
        internal static void Add(Rbr_Db pDb, ContactInfoDto pContactInfo)
        {
            ContactInfoRow _contactInfoRow = MapToContactInfoRow(pContactInfo);

            pDb.ContactInfoCollection.Insert(_contactInfoRow);
            pContactInfo.ContactInfoId = _contactInfoRow.Contact_info_id;
        }
        /// <summary>
        /// Updates a record in the <c>ContactInfo</c> table.
        /// </summary>
        /// <param name="value">The <see cref="ContactInfoRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(ContactInfoRow value)
        {
            string sqlStr = "UPDATE [dbo].[ContactInfo] SET " +
                            "[address1]=" + _db.CreateSqlParameterName("Address1") + ", " +
                            "[address2]=" + _db.CreateSqlParameterName("Address2") + ", " +
                            "[city]=" + _db.CreateSqlParameterName("City") + ", " +
                            "[state]=" + _db.CreateSqlParameterName("State") + ", " +
                            "[zip_code]=" + _db.CreateSqlParameterName("Zip_code") + ", " +
                            "[email]=" + _db.CreateSqlParameterName("Email") + ", " +
                            "[home_phone_number]=" + _db.CreateSqlParameterName("Home_phone_number") + ", " +
                            "[cell_phone_number]=" + _db.CreateSqlParameterName("Cell_phone_number") + ", " +
                            "[work_phone_number]=" + _db.CreateSqlParameterName("Work_phone_number") +
                            " WHERE " +
                            "[contact_info_id]=" + _db.CreateSqlParameterName("Contact_info_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Address1", value.Address1);
            AddParameter(cmd, "Address2", value.Address2);
            AddParameter(cmd, "City", value.City);
            AddParameter(cmd, "State", value.State);
            AddParameter(cmd, "Zip_code", value.Zip_code);
            AddParameter(cmd, "Email", value.Email);
            AddParameter(cmd, "Home_phone_number", value.Home_phone_number);
            AddParameter(cmd, "Cell_phone_number", value.Cell_phone_number);
            AddParameter(cmd, "Work_phone_number", value.Work_phone_number);
            AddParameter(cmd, "Contact_info_id", value.Contact_info_id);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <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="ContactInfoRow"/> objects.</returns>
        protected virtual ContactInfoRow[] 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 contact_info_idColumnIndex   = reader.GetOrdinal("contact_info_id");
            int address1ColumnIndex          = reader.GetOrdinal("address1");
            int address2ColumnIndex          = reader.GetOrdinal("address2");
            int cityColumnIndex              = reader.GetOrdinal("city");
            int stateColumnIndex             = reader.GetOrdinal("state");
            int zip_codeColumnIndex          = reader.GetOrdinal("zip_code");
            int emailColumnIndex             = reader.GetOrdinal("email");
            int home_phone_numberColumnIndex = reader.GetOrdinal("home_phone_number");
            int cell_phone_numberColumnIndex = reader.GetOrdinal("cell_phone_number");
            int work_phone_numberColumnIndex = reader.GetOrdinal("work_phone_number");

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

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

                    record.Contact_info_id   = Convert.ToInt32(reader.GetValue(contact_info_idColumnIndex));
                    record.Address1          = Convert.ToString(reader.GetValue(address1ColumnIndex));
                    record.Address2          = Convert.ToString(reader.GetValue(address2ColumnIndex));
                    record.City              = Convert.ToString(reader.GetValue(cityColumnIndex));
                    record.State             = Convert.ToString(reader.GetValue(stateColumnIndex));
                    record.Zip_code          = Convert.ToString(reader.GetValue(zip_codeColumnIndex));
                    record.Email             = Convert.ToString(reader.GetValue(emailColumnIndex));
                    record.Home_phone_number = Convert.ToInt64(reader.GetValue(home_phone_numberColumnIndex));
                    record.Cell_phone_number = Convert.ToInt64(reader.GetValue(cell_phone_numberColumnIndex));
                    record.Work_phone_number = Convert.ToInt64(reader.GetValue(work_phone_numberColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((ContactInfoRow[])(recordList.ToArray(typeof(ContactInfoRow))));
        }
Beispiel #4
0
        //----------------------------------- Privates ----------------------------------------------------------
        static void mapToPersonRow(PersonDto pPerson, out PersonRow pPersonRow, out ContactInfoRow pContactInfoRow)
        {
            pPersonRow      = null;
            pContactInfoRow = null;
            if (pPerson == null)
            {
                return;
            }

            pPersonRow = new PersonRow
            {
                Person_id          = pPerson.PersonId,
                Name               = pPerson.Name,
                Login              = pPerson.Login,
                Password           = pPerson.Password,
                AccessScope        = pPerson.AccessScope,
                PermissionType     = pPerson.PermissionType,
                RegistrationStatus = pPerson.RegistrationStatus,
                PersonStatus       = pPerson.Status,
                Salt               = pPerson.Salt
            };

            if (pPerson.VirtualSwitch != null)
            {
                pPersonRow.Virtual_switch_id = pPerson.VirtualSwitchId;
            }

            if (pPerson.PartnerId != 0)
            {
                pPersonRow.Partner_id = pPerson.PartnerId;
            }
            if (pPerson.RetailAcctId != 0)
            {
                pPersonRow.Retail_acct_id = pPerson.RetailAcctId;
            }
            if (pPerson.GroupId != 0)
            {
                pPersonRow.Group_id = pPerson.GroupId;
            }
            if (pPerson.ContactInfo != null)
            {
                pPersonRow.Contact_info_id        = pPerson.ContactInfoId;
                pContactInfoRow                   = new ContactInfoRow();
                pContactInfoRow.Contact_info_id   = pPerson.ContactInfo.ContactInfoId;
                pContactInfoRow.Address1          = pPerson.ContactInfo.Address1;
                pContactInfoRow.Address2          = pPerson.ContactInfo.Address2;
                pContactInfoRow.City              = pPerson.ContactInfo.City;
                pContactInfoRow.State             = pPerson.ContactInfo.State;
                pContactInfoRow.Zip_code          = pPerson.ContactInfo.Zip;
                pContactInfoRow.Email             = pPerson.ContactInfo.Email;
                pContactInfoRow.Work_phone_number = pPerson.ContactInfo.WorkPhone;
                pContactInfoRow.Home_phone_number = pPerson.ContactInfo.HomePhone;
                pContactInfoRow.Cell_phone_number = pPerson.ContactInfo.CellPhone;
            }
        }
Beispiel #5
0
        static internal ContactInfoDto MapToContactInfo(ContactInfoRow pContactInfoRow)
        {
            if (pContactInfoRow == null)
            {
                return(null);
            }
            ContactInfoDto _contactInfo = new ContactInfoDto();

            _contactInfo.ContactInfoId = pContactInfoRow.Contact_info_id;
            _contactInfo.Address1      = pContactInfoRow.Address1;
            _contactInfo.Address2      = pContactInfoRow.Address2;
            _contactInfo.City          = pContactInfoRow.City;
            _contactInfo.State         = pContactInfoRow.State;
            _contactInfo.Zip           = pContactInfoRow.Zip_code;
            _contactInfo.Email         = pContactInfoRow.Email;
            _contactInfo.HomePhone     = pContactInfoRow.Home_phone_number;
            _contactInfo.CellPhone     = pContactInfoRow.Cell_phone_number;
            _contactInfo.WorkPhone     = pContactInfoRow.Work_phone_number;

            return(_contactInfo);
        }
        /// <summary>
        /// Adds a new record into the <c>ContactInfo</c> table.
        /// </summary>
        /// <param name="value">The <see cref="ContactInfoRow"/> object to be inserted.</param>
        public virtual void Insert(ContactInfoRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[ContactInfo] (" +
                            "[contact_info_id], " +
                            "[address1], " +
                            "[address2], " +
                            "[city], " +
                            "[state], " +
                            "[zip_code], " +
                            "[email], " +
                            "[home_phone_number], " +
                            "[cell_phone_number], " +
                            "[work_phone_number]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Contact_info_id") + ", " +
                            _db.CreateSqlParameterName("Address1") + ", " +
                            _db.CreateSqlParameterName("Address2") + ", " +
                            _db.CreateSqlParameterName("City") + ", " +
                            _db.CreateSqlParameterName("State") + ", " +
                            _db.CreateSqlParameterName("Zip_code") + ", " +
                            _db.CreateSqlParameterName("Email") + ", " +
                            _db.CreateSqlParameterName("Home_phone_number") + ", " +
                            _db.CreateSqlParameterName("Cell_phone_number") + ", " +
                            _db.CreateSqlParameterName("Work_phone_number") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Contact_info_id", value.Contact_info_id);
            AddParameter(cmd, "Address1", value.Address1);
            AddParameter(cmd, "Address2", value.Address2);
            AddParameter(cmd, "City", value.City);
            AddParameter(cmd, "State", value.State);
            AddParameter(cmd, "Zip_code", value.Zip_code);
            AddParameter(cmd, "Email", value.Email);
            AddParameter(cmd, "Home_phone_number", value.Home_phone_number);
            AddParameter(cmd, "Cell_phone_number", value.Cell_phone_number);
            AddParameter(cmd, "Work_phone_number", value.Work_phone_number);
            cmd.ExecuteNonQuery();
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="ContactInfoRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="ContactInfoRow"/> object.</returns>
        protected virtual ContactInfoRow MapRow(DataRow row)
        {
            ContactInfoRow mappedObject = new ContactInfoRow();
            DataTable      dataTable    = row.Table;
            DataColumn     dataColumn;

            // Column "Contact_info_id"
            dataColumn = dataTable.Columns["Contact_info_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Contact_info_id = (int)row[dataColumn];
            }
            // Column "Address1"
            dataColumn = dataTable.Columns["Address1"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Address1 = (string)row[dataColumn];
            }
            // Column "Address2"
            dataColumn = dataTable.Columns["Address2"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Address2 = (string)row[dataColumn];
            }
            // Column "City"
            dataColumn = dataTable.Columns["City"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.City = (string)row[dataColumn];
            }
            // Column "State"
            dataColumn = dataTable.Columns["State"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.State = (string)row[dataColumn];
            }
            // Column "Zip_code"
            dataColumn = dataTable.Columns["Zip_code"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Zip_code = (string)row[dataColumn];
            }
            // Column "Email"
            dataColumn = dataTable.Columns["Email"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Email = (string)row[dataColumn];
            }
            // Column "Home_phone_number"
            dataColumn = dataTable.Columns["Home_phone_number"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Home_phone_number = (long)row[dataColumn];
            }
            // Column "Cell_phone_number"
            dataColumn = dataTable.Columns["Cell_phone_number"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Cell_phone_number = (long)row[dataColumn];
            }
            // Column "Work_phone_number"
            dataColumn = dataTable.Columns["Work_phone_number"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Work_phone_number = (long)row[dataColumn];
            }
            return(mappedObject);
        }
 /// <summary>
 /// Deletes the specified object from the <c>ContactInfo</c> table.
 /// </summary>
 /// <param name="value">The <see cref="ContactInfoRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(ContactInfoRow value)
 {
     return(DeleteByPrimaryKey(value.Contact_info_id));
 }
Beispiel #9
0
        internal static void Update(Rbr_Db pDb, ContactInfoDto pContactInfo)
        {
            ContactInfoRow _contactInfoRow = MapToContactInfoRow(pContactInfo);

            pDb.ContactInfoCollection.Update(_contactInfoRow);
        }
Beispiel #10
0
        internal static ContactInfoDto Get(Rbr_Db pDb, int pContactInfoId)
        {
            ContactInfoRow _contactInfoRow = pDb.ContactInfoCollection.GetByPrimaryKey(pContactInfoId);

            return(MapToContactInfo(_contactInfoRow));
        }