/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="PayphoneSurchargeRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="PayphoneSurchargeRow"/> object.</returns> protected virtual PayphoneSurchargeRow MapRow(DataRow row) { PayphoneSurchargeRow mappedObject = new PayphoneSurchargeRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Payphone_surcharge_id" dataColumn = dataTable.Columns["Payphone_surcharge_id"]; if (!row.IsNull(dataColumn)) { mappedObject.Payphone_surcharge_id = (int)row[dataColumn]; } // Column "Surcharge" dataColumn = dataTable.Columns["Surcharge"]; if (!row.IsNull(dataColumn)) { mappedObject.Surcharge = (decimal)row[dataColumn]; } // Column "Surcharge_type" dataColumn = dataTable.Columns["Surcharge_type"]; if (!row.IsNull(dataColumn)) { mappedObject.Surcharge_type = (byte)row[dataColumn]; } return(mappedObject); }
public static int AddPayphoneSurcharge(Rbr_Db pDb, PayphoneSurchargeDto pPayphoneSurcharge) { PayphoneSurchargeRow _payphoneSurchargeRow = MapToPayphoneSurchargeRow(pPayphoneSurcharge); pDb.PayphoneSurchargeCollection.Insert(_payphoneSurchargeRow); return(_payphoneSurchargeRow.Payphone_surcharge_id); }
/// <summary> /// Updates a record in the <c>PayphoneSurcharge</c> table. /// </summary> /// <param name="value">The <see cref="PayphoneSurchargeRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(PayphoneSurchargeRow value) { string sqlStr = "UPDATE [dbo].[PayphoneSurcharge] SET " + "[surcharge]=" + _db.CreateSqlParameterName("Surcharge") + ", " + "[surcharge_type]=" + _db.CreateSqlParameterName("Surcharge_type") + " WHERE " + "[payphone_surcharge_id]=" + _db.CreateSqlParameterName("Payphone_surcharge_id"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Surcharge", value.Surcharge); AddParameter(cmd, "Surcharge_type", value.Surcharge_type); AddParameter(cmd, "Payphone_surcharge_id", value.Payphone_surcharge_id); return(0 != cmd.ExecuteNonQuery()); }
public static PayphoneSurchargeRow MapToPayphoneSurchargeRow(PayphoneSurchargeDto pPayphoneSurcharge) { if (pPayphoneSurcharge == null) { return(null); } var _payphoneSurchargeRow = new PayphoneSurchargeRow(); _payphoneSurchargeRow.Payphone_surcharge_id = pPayphoneSurcharge.PayphoneSurchargeId; _payphoneSurchargeRow.Surcharge = pPayphoneSurcharge.Surcharge; _payphoneSurchargeRow.SurchargeType = pPayphoneSurcharge.SurchargeType; return(_payphoneSurchargeRow); }
/// <summary> /// Adds a new record into the <c>PayphoneSurcharge</c> table. /// </summary> /// <param name="value">The <see cref="PayphoneSurchargeRow"/> object to be inserted.</param> public virtual void Insert(PayphoneSurchargeRow value) { string sqlStr = "INSERT INTO [dbo].[PayphoneSurcharge] (" + "[payphone_surcharge_id], " + "[surcharge], " + "[surcharge_type]" + ") VALUES (" + _db.CreateSqlParameterName("Payphone_surcharge_id") + ", " + _db.CreateSqlParameterName("Surcharge") + ", " + _db.CreateSqlParameterName("Surcharge_type") + ")"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Payphone_surcharge_id", value.Payphone_surcharge_id); AddParameter(cmd, "Surcharge", value.Surcharge); AddParameter(cmd, "Surcharge_type", value.Surcharge_type); 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="PayphoneSurchargeRow"/> objects.</returns> protected virtual PayphoneSurchargeRow[] 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 payphone_surcharge_idColumnIndex = reader.GetOrdinal("payphone_surcharge_id"); int surchargeColumnIndex = reader.GetOrdinal("surcharge"); int surcharge_typeColumnIndex = reader.GetOrdinal("surcharge_type"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { PayphoneSurchargeRow record = new PayphoneSurchargeRow(); recordList.Add(record); record.Payphone_surcharge_id = Convert.ToInt32(reader.GetValue(payphone_surcharge_idColumnIndex)); record.Surcharge = Convert.ToDecimal(reader.GetValue(surchargeColumnIndex)); record.Surcharge_type = Convert.ToByte(reader.GetValue(surcharge_typeColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((PayphoneSurchargeRow[])(recordList.ToArray(typeof(PayphoneSurchargeRow)))); }
static ServiceDto getService(Rbr_Db pDb, ServiceRow pServiceRow, short pCustomerAcctId) { if (pServiceRow == null) { return(null); } AccessNumberListRow[] _accessNumberRows; if (pCustomerAcctId > 0) { _accessNumberRows = pDb.AccessNumberListCollection.GetByCustomer_acct_id(pCustomerAcctId); } else { _accessNumberRows = pDb.AccessNumberListCollection.GetByService_id(pServiceRow.Service_id); } var _defaultRoutingPlan = RoutingManager.GetRoutingPlan(pDb, pServiceRow.Default_routing_plan_id); PayphoneSurchargeRow _payphoneSurchargeRow = null; if (!pServiceRow.IsPayphone_surcharge_idNull) { _payphoneSurchargeRow = pDb.PayphoneSurchargeCollection.GetByPrimaryKey(pServiceRow.Payphone_surcharge_id); } //if (pServiceRow.IsRatingEnabled) { //NOTE: DefaultRatingInfo is always created no metter what //and it should be loaded as well no metter what var _defaultRatingInfo = getDefaultServiceRatingInfo(pDb, pServiceRow.Service_id); //} var _service = mapToService(pServiceRow, _defaultRoutingPlan, _payphoneSurchargeRow, _accessNumberRows, _defaultRatingInfo); //NOTE: DefaultServiceRoute's ID = [negative] -ServiceId var _defaultWholesaleRouteRow = pDb.WholesaleRouteCollection.GetByPrimaryKey(-pServiceRow.Service_id); _service.DefaultRoute = CustomerRouteManager.Get(pDb, _service, _service.DefaultRoutingPlanId, _defaultWholesaleRouteRow); return(_service); }
/// <summary> /// Deletes the specified object from the <c>PayphoneSurcharge</c> table. /// </summary> /// <param name="value">The <see cref="PayphoneSurchargeRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(PayphoneSurchargeRow value) { return(DeleteByPrimaryKey(value.Payphone_surcharge_id)); }
public static void UpdatePayphoneSurcharge(Rbr_Db pDb, ServiceDto pService) { PayphoneSurchargeRow _payphoneSurchargeRow = MapToPayphoneSurchargeRow(pService.PayphoneSurcharge); pDb.PayphoneSurchargeCollection.Update(_payphoneSurchargeRow); }
static ServiceDto mapToService(ServiceRow pServiceRow, RoutingPlanDto pDefaultRoutingPlan, PayphoneSurchargeRow pPayphoneSurchargeRow, ICollection <AccessNumberListRow> pAccessNumberListRows, RatingInfoDto pDefaultRatingInfo) { if (pServiceRow == null) { return(null); } var _service = new ServiceDto { ServiceId = pServiceRow.Service_id, Name = pServiceRow.Name, Status = ((Status)pServiceRow.Status), ServiceType = pServiceRow.ServiceType, RetailType = pServiceRow.RetailType, IsShared = pServiceRow.IsShared, RatingType = pServiceRow.RatingType, PinLength = pServiceRow.Pin_length, DefaultRatingInfo = pDefaultRatingInfo, DefaultRoutingPlan = pDefaultRoutingPlan, AccessNumbers = mapToAccessNumbers(pAccessNumberListRows), PayphoneSurcharge = RetailAccountManager.MapToPayphoneSurcharge(pPayphoneSurchargeRow), SweepScheduleId = pServiceRow.Sweep_schedule_id, SweepFee = pServiceRow.Sweep_fee, SweepRule = pServiceRow.Sweep_rule, BalancePromptType = pServiceRow.BalancePromptType, BalancePromptPerUnit = pServiceRow.Balance_prompt_per_unit, VirtualSwitchId = pServiceRow.Virtual_switch_id }; return(_service); }